Redirect after submitting form with react-router-dom?

0

Good afternoon guys, are you okay?

The situation is as follows, I'm using the react-router-dom in an application in ReactJS and need to after saving on a form, it goes to the list screen, showing the new record. At first with the react-router-dom {Link} I can redirect, but I can not get the CRUD list updated.

Would anyone help me with this?

Thank you!

    
asked by anonymous 16.01.2018 / 23:20

1 answer

1

Probably because in router redirection your component is not getting the updated state, so when returning to the crud listing you should add some method like the shouldComponentUpdate or componentWillReceiveProps to get the list component to take the state of your application. Remember, when you transition between components via a router, your component is not initialized with the entire path (componentWillMount, componentDidMount, and so on).

    
18.01.2018 / 17:47