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

Better NextJS integration #6457

Open
ryyppy opened this issue Oct 30, 2023 · 3 comments
Open

Better NextJS integration #6457

ryyppy opened this issue Oct 30, 2023 · 3 comments
Milestone

Comments

@ryyppy
Copy link
Member

ryyppy commented Oct 30, 2023

Given we want to be able to provide better integration with existing JS frameworks to provide guided stories, the following blockers for NextJS should be (re-)assessed:

  1. Exotic filenames: Right now, NextJS heavily relies on exotic filenames / duplicated filenames, which requires ReScript users to re-export ReScript components in shim JS files in the pages and app directoy
  2. Shared props for getStaticProps / default export: Previously, one had to fall back to let default = (props) => {} just to be able to share the props between the consuming component and getServerProps etc. ... I think this should be solved with @mununki's new JSX 4, which should be able to provide a custom prop type to a @react.component decorator
  3. Props serialization with undefined props: Previously, serializing props from getServerProps etc. will cause the frontend to break, because foo: undefined is not valid JSON (it gets passed as a string and then JSON.parsed). This should be fixed with optional attributes (e.g. {foo ?: string})
  4. Function level directives ("use server";): As for right now, it is only possible to provide those directives on the module level. We'd need a way to maintain directives on a JS function level

(Please note: The provided list is kept short, details should be refined in linked issues if there's any need to solve a problem)

@ryyppy ryyppy added this to the v12 milestone Oct 30, 2023
@LukasDeco
Copy link

Not sure if I should make a new issue for this, but since I saw this one I thought it could be a good option for a place. I noticed some weird issues with the Js.Promise2 module. It was causing the app to bomb with a very vague error. The error when logged looks something like this: [Function (anonymous)] as you can see not very descriptive. So I'm not sure what the issue is. I switched to Js.Promise for now but this uses pipe-last of course so it would be nice if we could use Promise2.

@jderochervlk
Copy link

Related: #5950

@cometkim
Copy link
Member

cometkim commented Apr 22, 2024

Not sure if I should make a new issue for this, but since I saw this one I thought it could be a good option for a place. I noticed some weird issues with the Js.Promise2 module. It was causing the app to bomb with a very vague error. The error when logged looks something like this: [Function (anonymous)] as you can see not very descriptive. So I'm not sure what the issue is. I switched to Js.Promise for now but this uses pipe-last of course so it would be nice if we could use Promise2.

The next version(v19, already in use) of React treats promises as first-class type (can be used as child element!) So now having your own runtime representation for promises can be problematic.

Note: it is available regardless of using RSC or not, see an example

see also facebook/react#25634

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants