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

[Bug?]:TypeError: Cannot set properties of null (setting 'className') #1622

Closed
2 tasks done
nbrugger-tgm opened this issue Sep 9, 2024 · 2 comments
Closed
2 tasks done
Labels
bug Something isn't working

Comments

@nbrugger-tgm
Copy link

nbrugger-tgm commented Sep 9, 2024

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

On any change that causes a reload (HMR) i get the error message Cannot set properties of null (setting 'className') at dev.js:166. I do not use className as jsx/tsx property.

Expected behavior 🤔

When i do a HMR change solid doesn't "crash" and displays the changes made to the sourcecode (unless there is an error in my code) OR throws an error message that i can fix

Steps to reproduce 🕹

Either see: https://stackblitz.com/edit/solidjs-templates-7xy2wh?file=src%2FApp.tsx and open preview in new tab

OR

  1. Create a solid start project with TSX
  2. copy paste the following snippet into the src/routes/index.tsx
import {createSignal} from "solid-js";

export default (props: { user: string | null }) => {
  const [open, setOpen] = createSignal(false);
  return (
    <a
      class={`border-base-140 border rounded-md absolute right-1.5 top-1.5 bg-base-80 flex align-middle items-center justify-around flex-col ${props.user == null ? "text-primary-dark" : "text-accent/60 hover:text-primary-dark/60"} animated-500 outline-0 hover:border-primary/30 hoverGlow hover:shadow-primary/10`}
      style="--ggs: 1.5"
      onClick={() => {
        if (props.user != null) setOpen(bool => !bool);
      }}
      onMouseLeave={() => setOpen(false)}
      href={props.user !== null ? undefined : "/auth"}
    >
      <div class="p-2 flex align-middle items-center justify-around cursor-pointer gap-2">
        <span>{props.user ?? "Login"}</span>
      </div>
      <div class={`flex-col flex w-full ${open() ? "":"hidden"}`}>
        <hr class="border-secondary m-0 p-0" />
        <div class="flex-col flex w-full gap-2 p-2">
          <a
            class="text-accent font-medium cursor-pointer hover:bg-black/20 hover:text-primary-dark/80 rounded p-1 animated-300"
            href="/deauth"
          >
            Logout
          </a>
          <a
            href="redacted"
            class="text-accent font-medium cursor-pointer hover:bg-black/20 hover:text-primary-dark/80 rounded p-1 animated-300"
          >
            Edit User
          </a>
        </div>
      </div>
    </a>
  );
};
  1. go to the browser watch it working fine
  2. change a line "Edit user" to "YOLO"
  3. See the crash in the open tab

Context 🔦

There is not a lot to say - it crashes on every single change :(

I left so much code in the snippet above since i have no clue what triggers it and it would be very tedious to remove every class every attribute one by one

Upon inspecting it seems like the JSX transformed code is just wrong. lastSibling is used to access the <div class={flex-col flex w-full ${open() ? "fuk you i guess":"hidden"}}> node but well that returns null

Your environment 🌎

OS: Kubuntu 24.04.1 LTS x86_64
CPU: AMD Ryzen 7 PRO 4750U with Radeon Graphics (16) @ 1.700GHz

npm: 10.1.0
bun: 1.1.26 (tested with both npm/bun in isolation)

solid-start: 1.0.6
@nbrugger-tgm
Copy link
Author

There is now a stackblitz reproducer https://stackblitz.com/edit/solidjs-templates-7xy2wh?file=src%2FApp.tsx and a solid ticket: #2279

@nbrugger-tgm
Copy link
Author

The ticket in solid-js is more up to date and this is not related to solid-start itself

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant