Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const withApollo = PageComponent => {
return class extends React.Component {
static displayName = `withApollo(${getDisplayName(PageComponent)})`;
static async getInitialProps(ctx) {
const { AppTree } = ctx;
let pageProps = {};
if (PageComponent.getInitialProps) {
pageProps = await PageComponent.getInitialProps(ctx);
}
// Run all GraphQL queries in the component tree
// and extract the resulting data
const apolloClient = initApollo(
{},
{
getToken: () => parseCookies(ctx.req).token,
}
export default function withRouter (ComposedComponent) {
const displayName = getDisplayName(ComposedComponent)
function WithRouteWrapper (props) {
return (
{router => (
)}
)
}
WithRouteWrapper.displayName = `withRouter(${displayName})`