Search code examples
reactjsreact-routerstatereact-propspathname

How to keep the props.location.state after refreshing page?(without using local storagre)


I used this Link , when i refresh the page props.location.state === null any solution to keep the data in props.location.state when refreshing or charging new pages without using local storage?

<Link to={{ pathname: `/details/${imdbID}`, state: this.props }}>


Solution

  • No need to store the data you need in local storage, you can dump in any place and with or without refreshing the data will be always here just in routing we need to use propWhatever example:

    <Route path="/details" render={(props)=> (
            
              <Details {...props}   propWhatever={{data}} />
              )} />