-
Notifications
You must be signed in to change notification settings - Fork 682
/
adapter.js
40 lines (34 loc) · 1.22 KB
/
adapter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import React from 'react';
import { ApolloProvider } from '@apollo/client';
import { Provider as ReduxProvider } from 'react-redux';
import { BrowserRouter } from 'react-router-dom';
import { useAdapter } from '@magento/peregrine/lib/talons/Adapter/useAdapter';
import App, { AppContextProvider } from '@magento/venia-ui/lib/components/App';
import StoreCodeRoute from '@magento/venia-ui/lib/components/StoreCodeRoute';
const Adapter = props => {
const talonProps = useAdapter(props);
const {
apolloProps,
initialized,
reduxProps,
routerProps,
urlHasStoreCode
} = talonProps;
// TODO: Replace with app skeleton. See PWA-547.
if (!initialized) {
return null;
}
const children = props.children || <App />;
const storeCodeRouteHandler = urlHasStoreCode ? <StoreCodeRoute /> : null;
return (
<ApolloProvider {...apolloProps}>
<ReduxProvider {...reduxProps}>
<BrowserRouter {...routerProps}>
{storeCodeRouteHandler}
<AppContextProvider>{children}</AppContextProvider>
</BrowserRouter>
</ReduxProvider>
</ApolloProvider>
);
};
export default Adapter;