+ 1
Can I transfer a state item in react from first component to second component!
10 odpowiedzi
+ 7
I don't have a proper way to do that but what strikes on my mind is :
When you render second component you can pass that state item as prop.
That's not the best way I know.
Calviղ can help maybe.
+ 5
Here a simple sample of passing a state from parent to children component through attribute props in React Hooks.
https://code.sololearn.com/W5do6CUTXXq1/?ref=app
+ 4
Yes mate. Let me try it.
+ 3
Thanks for suggestion Raj Chhatrala!
+ 3
You can pass state from parent to child. Or the opposite way : from child to parent.
https://dev.to/zeyadetman/how-to-pass-state-between-components-in-reactjs-2pg1
If not ancestor-descendant, route via App.
+ 2
Raj can you give me example!
+ 2
Thanks!
+ 2
Guys,I make it!
https://code.sololearn.com/WcSgm8aBX9la/?ref=app
+ 1
What is the problem!?
0
🇲🇰Maksi - Vik🇲🇰 your code has syntax error, cannot run.