mardi 23 juillet 2019

I have a problem with redirection in React

I am new to react and i am creating a simple Contact Manager App, i have contacts and addContact components, these are separated in different routes. When i add a contact,it gets added to the local storage and the contacts component is getting the list of contacts from the local storage. The problem that when i add a contact and i redirect to the contacts page, the new contact doesn't show unless i manually refresh the page.

i tried this :

this.props.history.push('/');

this too

window.location.href=window.location.hostname;

and i created a function to refresh the page if the previous link is the addContact link, it doesn't work either




Aucun commentaire:

Enregistrer un commentaire