O
O
oddwang2022-02-24 17:51:24
React
oddwang, 2022-02-24 17:51:24

How to get information in an input and then display it using localStorage in another component?

I enter the login into the input, then by clicking on the button it is saved in localStorage. How can I display the received item named user in another component, when it has already rendered, using localStorage?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Valery, 2022-02-25
@vmakhnyuk

I enter the login into the input, then by clicking on the button it is saved in localStorage.

localStorage.setItem('inputData', e.target.value)
How can I display the received item named user in another component, when it has already rendered, using localStorage?

const inputData = localStorage.getItem('inputData');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question