Skip to content

Overrided property by undefined in mergeProps #1383

Closed

Description

@juanrgm

https://stackblitz.com/edit/github-pkoqsx?file=src%2Froot.tsx

import { mergeProps } from 'solid-js';

// @refresh reload
export default function Root() {
  const props = mergeProps(
    {
      value: 1,
    },
    {
      get value() {
        return undefined;
      },
    }
  );
  return <>props.value: {props.value}</>; // props.value: undefined
}

https://playground.solidjs.com/anonymous/224b34ac-6a3a-4a9d-b837-f47c90398f94

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

function Root() {
  const props = mergeProps(
    {
      value: 1,
    },
    {
      get value() {
        return undefined;
      },
    }
  );
  return <>props.value: {props.value}</>; // props.value: 1
}

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

Activity

  1. orenelbaum commented on Dec 3, 2022

    @orenelbaum
    Contributor

    This issue happens only with SSR. It doesn't happen in a normal Solid project or with Solid Start with SSR turned off.

  2. ryansolid commented on Dec 3, 2022

    @ryansolid
    Member

    It's a DOM Expressions problem. But I consider SSR in Solid's responsibility. SolidStart is just a template/cli/collection of Vite plugins.

  3. orenelbaum commented on Dec 3, 2022

    @orenelbaum
    Contributor

    I actually found the problem, it's in the server version of mergeProps, I'll fix it, I just want to make sure I fix it properly

  4. orenelbaum commented on Dec 3, 2022

    @orenelbaum
    Contributor

    Another fun bug, if you replace the props object with:

    const props = mergeProps(() => ({ value: 1 }));
    props.value = 2;

    With ssr you'd get the value 2 but without ssr you'd get the value 1.

    If you go instead with

    const props = mergeProps({ value: 1 })
    props.value = 2;

    With ssr you'd get the value 2 again but without ssr it will throw an error.

  5. orenelbaum commented on Dec 4, 2022

    @orenelbaum
    Contributor

    I'll link this here for now
    ryansolid/dom-expressions@9d43854

  6. fongandrew commented on Jan 15, 2025

    @fongandrew

    Just wanted to note that this change caused an issue for me. The specific thing I was trying to do:

    // Replace `invalid` with `aria-invalid` since `invalid` isn't a proper HTML attribute
    <input {...props} aria-invalid={props.invalid} invalid={undefined} />

    The expectation was that this would work because { ...({ foo: 'bar' }), ...({ foo: undefined }) } replaces the foo property with undefined in plain JavaScript. There are workarounds around (use null or splitProps instead) but this behavior was a bit unexpected.

  7. added a commit that references this issue on Nov 12, 2025
    7b3a660
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions