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

Plans to fetch data using co-location within JSX #203

Closed
noahlst opened this issue Oct 28, 2021 · 6 comments
Closed

Plans to fetch data using co-location within JSX #203

noahlst opened this issue Oct 28, 2021 · 6 comments
Labels
feature-request New feature or request

Comments

@noahlst
Copy link

noahlst commented Oct 28, 2021

The newly announced Next.js 12 signals a future shift by the Next team to move away from 'data functions' like getStaticProps to co-locating data collection within JSX.

Builds using experimental React 18 (which is in alpha) features - like SSR and RSC - on Next 12 currently fail.

Are there plans to adapt the next-mdx-remote package into this new model?

@jescalan
Copy link
Contributor

Yes

@jescalan jescalan added the feature-request New feature or request label Nov 3, 2021
stormwild added a commit to stormwild/next-mdx-remote that referenced this issue Apr 2, 2022
@gamedevsam
Copy link

I get errors with React 18:

Module not found: Package path ./jsx-runtime.js is not exported from package /home/sbatista/Dev/Personal/sambatista.com/node_modules/react (see exports field in /home/sbatista/Dev/Personal/sambatista.com/node_modules/react/package.json)

@noahlst noahlst changed the title Plans to adapt to Next 12 and React 18 Plans to fetch data using co-location within JSX Apr 7, 2022
@noahlst
Copy link
Author

noahlst commented Apr 7, 2022

Hi team! The original purpose of this issue was really based on two parts — hooks/colocating as raised at Next.js Conf 2021; and React SSR/Server Components. With React 18 now in GA and 4.0.1 capable of <Suspense>, SSR, etc (#255, #250, #237, more), I've renamed this to focus on the latter only.

@noahlst
Copy link
Author

noahlst commented Apr 7, 2022

At this time, if you're experiencing errors with React 18 concurrency features, check:

  • that next-mdx-remote is pinned at version 4.0.1
  • that you are using the latest version of Next.js (12.1.4 at writing)
  • that you're using the latest version of React (i.e. 18.0.0 proper)
  • that your next.config.js includes experimental: { runtime: "nodejs"} (Edge Runtime disables eval which this library requires)

If none of that works try adding this to your next.config.js:

webpack: (config) => {
    config.resolve.alias = {
      ...config.resolve.alias,
      "react/jsx-runtime.js": path.resolve("node_modules/react/jsx-runtime"),
    };
    return config;
  },

Or you can try require.resolve instead of path. This is courtesy of @jakejarvis

Note that, with time, this will probably break!

@gamedevsam
Copy link

@fernpolo pinning next-mdx-remote to version 4.0.1 solved the problem for me for now. Thanks for the update!

@BRKalow
Copy link
Contributor

BRKalow commented May 29, 2022

Closing this for now, thanks for raising the question! We'll be following the progress of the data-fetching evolutions in Next.js and look at how we'll be able to update next-mdx-remote to fit into the new patterns as more information comes out.

@BRKalow BRKalow closed this as completed May 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants