title: Simple React Error: Can't use @material-ui/picker library in Next.js
body: <p>I'm trying to use the <a href="https://material-ui-pickers.dev/getting-started/installation" rel="nofollow noreferrer">@material-ui/pickers</a> library within a Next.js app.</p>
  <p>I added the <code>_app.js</code> file inside <code>/pages</code> as <a href="https://nextjs.org/docs/advanced-features/custom-app" rel="nofollow noreferrer">indicated in the Next.js docs</a> as a place to put the Picker provider:</p>
  <pre><code>import React from &quot;react&quot;;
  import PropTypes from &quot;prop-types&quot;;
  import { ThemeProvider } from &quot;@material-ui/core/styles&quot;;
  import { MuiPickersUtilsProvider } from &quot;@material-ui/pickers&quot;;
  import DateFnsUtils from &quot;@date-io/date-fns&quot;; // using version 1.x as described in the docs
  import CssBaseline from &quot;@material-ui/core/CssBaseline&quot;;
  import theme from &quot;../src/theme&quot;;
  
  export default function MyApp(props) {
    const { Component, pageProps } = props;
  
    React.useEffect(() =&gt; {
      // Remove the server-side injected CSS.
      const jssStyles = document.querySelector(&quot;#jss-server-side&quot;);
      if (jssStyles) {
        jssStyles.parentElement.removeChild(jssStyles);
      }
    }, []);
  
    return (
      &lt;React.Fragment&gt;
        &lt;ThemeProvider theme={theme}&gt;
          &lt;CssBaseline /&gt;
          &lt;MuiPickersUtilsProvider utils={DateFnsUtils}&gt;
            &lt;div&gt;Hello&lt;/div&gt;
            &lt;Component {...pageProps} /&gt;
          &lt;/MuiPickersUtilsProvider&gt;
        &lt;/ThemeProvider&gt;
      &lt;/React.Fragment&gt;
    );
  }
  </code></pre>
  <p>Code Sandbox example:<br />
  <a href="https://codesandbox.io/s/crimson-rgb-cqg5p?file=/pages/_app.js" rel="nofollow noreferrer">https://codesandbox.io/s/crimson-rgb-cqg5p?file=/pages/_app.js</a></p>
  <p>The server won't start up with this setup for some reason. When doing a SPA react app (without Next.js), it works fine. Adding Next.js though causes issues. Any help is appreciated.</p>