user1283776
user1283776

Reputation: 21764

Can I wrap my application with both a redux provider and an apollo provider?

Can I wrap my application with both a from 'react-redux' and an from 'react-apollo' or should I choose one or the other?

Several examples I have read on using Apollo for optimistic UI contrast it to creating the same result in redux and how much work that would be.

I'm already using redux and redux-saga in an application and am considering whether I should use the Apollo client for more things than for just making requests.

Here is a code example of what I am doing:

return (
    <ApolloProvider client={client}>
        <Provider store={store}>
            <ConnectedRouter history={history}>
                <ScrollToTop>
                    <App />
                </ScrollToTop>
            </ConnectedRouter>
        </Provider>
    </ApolloProvider>
);

Upvotes: 2

Views: 942

Answers (1)

xadm
xadm

Reputation: 8418

You're wrapping router provider, too - theme, contexts ... nothing wrong with multiple providers ;)

Local state can be used instead redux for some shared app state/data/logic (resolvers) but redux can still have an advantage in many cases.

Upvotes: 4

Related Questions