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

with-apollo breaks with #8801 #10453

Closed
fev4 opened this issue Feb 7, 2020 · 3 comments
Closed

with-apollo breaks with #8801 #10453

fev4 opened this issue Feb 7, 2020 · 3 comments

Comments

@fev4
Copy link

fev4 commented Feb 7, 2020

Examples bug report

Example name

with-apollo

Describe the bug

Getting this error:

Warning: Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it.
    in Unknown (at _app.js:24)
    in ThemeProvider (at _app.js:23)
    in WagglioMainApp
    in Container (created by AppContainer)
    in AppContainer

Current _app.js looks like this:

import 'cross-fetch/polyfill';
import App from 'next/app';
import React from 'react';
import { ThemeProvider } from 'styled-components';

const theme = {};

class WagglioMainApp extends App {
  // removed getInitialProps due to this https://github.com/zeit/next.js/blob/master/errors/opt-out-automatic-prerendering.md

  // This function is for Material UI
  componentDidMount() {
    // Remove the server-side injected CSS.
    const jssStyles = document.querySelector('#jss-server-side');
    if (jssStyles) {
      jssStyles.parentNode.removeChild(jssStyles);
    }
  }

  render() {
    const { Component, pageProps } = this.props;
    return (
      <ThemeProvider theme={theme}>
        <Component {...pageProps} />
      </ThemeProvider>
    );
  }
}

export default WagglioMainApp;

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Add both Material-UI and styled-components
  2. Implement with-apollo Make withApollo work with _app.js components #8801

Expected behavior

App should start without errors

System information

  • OS: MacOS
  • Version of Next.js: 9.2.1
@HaNdTriX
Copy link
Contributor

HaNdTriX commented Feb 7, 2020

Please note that there was a breaking change introduced in #10422.

-- export default withApollo(PageComponent, { ssr: true })
++ export default withApollo({ ssr: true })(PageComponent)

From your error message I would guess that this change might be related to your bug report.

@fev4
Copy link
Author

fev4 commented Feb 7, 2020

@HaNdTriX totally right! Completely missed that one. Thanks for pointing it out and thanks for the work with the apollo example. It has been very helpful!

Closing.

@fev4 fev4 closed this as completed Feb 7, 2020
@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants