Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query using already fetched data from redux store #57

Open
planetcrypton opened this issue Apr 25, 2018 · 3 comments
Open

Query using already fetched data from redux store #57

planetcrypton opened this issue Apr 25, 2018 · 3 comments

Comments

@planetcrypton
Copy link

planetcrypton commented Apr 25, 2018

I my our setup we want the query HOC to fetch the data, save it in the redux store (which it obviously does), but reuse that data, when its component is mounted for a second time, and avoid that extra http call.
What would be a good way of achieving this?

@stueynet
Copy link

We have a similar issue. We are using getRelationship as follows:

@query('message', api.getMessage, (perform, props) => (
    perform({ threadId: props.match.params.threadId, messageId: props.messageId, include: 'user' })
))

@connect((state, props) => {
    return (
        {
            user: props.message && getRelationship(state, props.message, 'user')
        }
    )
})

We would expect that once the related resources (users) are loaded, it should not require another api call at least for a specified amount of time. What we are finding is that each time we load the same message list, it makes all the individual user api calls as well for each message.

@benjy
Copy link

benjy commented Jul 19, 2018

I started off working around this by having the data fetched in a parent component that isn't unmounted and then passed through as props, that doesn't very well at all though.

My current solution is to have query check if the request has started before calling fetch: #59

@stueynet
Copy link

Anybody home here? @benjy your PR seems to work well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants