You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Client: problem - the users list will reload everytime we navigate to /user/:username
Question: Does we have any way to prevent reloading users everytime we navigate to /user/:username?
Can we provide current state in fetch function like this?
consthooks={fetch: ({ dispatch,query: { keyword, repos, followers }, entities })=>{if(!entities){// Only reload entities when entities doesn't exists to prevent duplicated loadreturndispatch(getUsers({ keyword, repos, followers }))}}}
The text was updated successfully, but these errors were encountered:
@joehua87, you can pass store through locals and then check the global state, e.g.
// Set up Redux (note: this API requires redux@>=3.1.0):conststore=createStore(reducer,initialState,applyMiddleware(thunk));// Listen for route changes on the browser history instance:browserHistory.listen(location=>{// Match routes based on location object:match({ routes, location },(error,redirectLocation,renderProps)=>{// Get array of route handler components:const{ components }=renderProps;// Define locals to be provided to all lifecycle hooks:constlocals={path: renderProps.location.pathname,query: renderProps.location.query,params: renderProps.params,// ----------CHANGED-------- Pass store here
store
};
...
});});
Use store.getState() in your hooks:
consthooks={fetch: ({store: {dispatch, getState},params: { id }})=>{if(!getState().entities)returndispatch(getSomething(id));}}};
Hello, Thank you for your awesome lib, it helps a lot 😃
I face some problem when working with nested route.
Given we have route like:
Question: Does we have any way to prevent reloading users everytime we navigate to /user/:username?
Can we provide current state in fetch function like this?
The text was updated successfully, but these errors were encountered: