last day (15 days later) » 

4:45 PM
0
Q: How to pass `props` data from parent to child on react router

Tanmoy SarkarI want to pass my props data from parent to child when it will route to new path. I tried some https://github.com/ReactTraining/react-router/issues/4105 but not actually worked when i passed it through {...props}. any help would be greatful. //App.js class App extends Component{ constructor(...

 
@AlexanderStaroselsky yes from postbook i want to pass it to allBook so that all my books will be visible there. But on changing to router props data are not storing any value.
@AlexanderStaroselsky yes i am getting posts from redux store. What i need to change then?
@AdolfoOnrubia mmm not sure. What do you think i need to change here ? I have updated my code.
@AdolfoOnrubia could you please add you answer.
 
Hi Tanmoy, cana you please also add PostBook component's code that you use to change routes to AllBook? I have something in my mind I wanna verify, specially the
 
@SultanH. here it is .. updated
 
Great, thanks, I can't find anything in the PostBook component about changing the route to AllBook, so, how do you change the route from PostBook to AllBook?
 
@SultanH. currently i am checking manually with /abc
 
4:45 PM
So, you basically write http://localhost:3000/abc from the URL bar in the browseR?
 
@SultanH. yes currently i am checking like this only. but will change later
 
I have added an answer below explaining what happens, please check it, and let me know if you need help setting up Link in your app.
 
@SultanH. yes please it will be really helpful then
 
Hi Tanmoy
Have you read the answer?
 
Hi sultan
yes i go through the answer.
 
4:45 PM
There is nothing wrong with the code.
I believe.
 
and it is expecting as i doing it manually
 
yes
 
so what do you think i cna do it here.
 
if you do that manually, you lose the data from Redux Store.
to test whether the functionality works or not
 
i am doing post and previously it is displaying in the same page but i want to store the date in different link or route
 
4:46 PM
You need to add a link in your PostBook to navigate to AllBook after submitting a book.
If the book is there after navigating using the Link then your code is fine
There is a lot to do about that.
You may need to store your data to a localStorage instant to save it from removal after a refresh, or more genuinly, have a back-end and a Database to store the data.
but currently, I'll modify my answer, so you may have a Link to do a Correct SPA Routing
 
yes please.
 
And I'll post a link where you can learn about using localStorage with React
Agreed?
 
i dont want currntly to add backend data.
sure please. it will be good for me
 
Ok, I am on it!
Updated my answer, please check and let me know if it works.
if after trying this, the book didn't show in the AllBooks route, pleaes let me know to find out what went wrong.
 
yes it worked... i found what actually i did wrong.... u r gekious
*genious
 
4:58 PM
I am only used to, not especially genious! you'll get used to this kind of things
In a minute I 'll be posting some References in the comments of my answer to give you some better understanding about routing. please check them
I am glad we figured this out ;)
Good Luck!
 
yes sure.. Can i have your email id... if you don't mind...
 
Dunno if sharing this is legal here, but here is a hint: Check my Stack Overflow profile :D
 
got it :D
 
Thanks Tanmoy, Good bye for now!
I have added a good article to the answer, check it out!
:+1:
 
sure i will do .. Thank you for all your effort.
please upvote my question if it will helpful somehow..
 

last day (15 days later) »