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

mergeProps fails with SSR #1875

Closed
juanrgm opened this issue Sep 7, 2023 · 3 comments
Closed

mergeProps fails with SSR #1875

juanrgm opened this issue Sep 7, 2023 · 3 comments

Comments

@juanrgm
Copy link
Contributor

juanrgm commented Sep 7, 2023

Describe the bug

This code throws an exception only with SSR enabled:

import { render } from "solid-js/web";

function Div(props: any) {
  return <div {...props} />;
}

function App() {
  // `data-firstprop` and `undefined` together cause the error
  const props = () => undefined as any;
  return (
    <Div data-firstprop {...props()}>
      test
    </Div>
  );
}

render(() => <App />, document.getElementById("app")!);

Your Example Website or App

https://playground.solidjs.com/anonymous/d1fa8058-4207-41c8-98fe-591be0d25909

Steps to Reproduce the Bug or Issue

  1. Execute the code with SSR enabled.

Expected behavior

No error.

Screenshots or Videos

No response

Platform

  • SolidJS: 1.7.11

Additional context

No response

@ryansolid
Copy link
Member

What's the error? The reproduction just shows code but no error message. If I can get a working reproduction, maybe Stackblitz or at least a posting of what the error message is.

@juanrgm
Copy link
Contributor Author

juanrgm commented Sep 9, 2023

I tried to create an example on Stackblitz, but NodeJS 18 is not supported yet (stackblitz/webcontainer-core#560).

You can download it (https://stackblitz.com/edit/solid-ssr-vite-c8xxyw?file=src%2FApp.tsx) and run it locally.

The error is:

An unhandled error occured: TypeError: Cannot read properties of undefined (reading 'data-firstprop')

And the problem is here.

@ryansolid
Copy link
Member

I see the server side merge props is much "simpler" and isn't handling undefined case properly. It must try to read it through undefined..

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

2 participants