Type '() => JSX.Element' is not assignable to type 'Element'
I'm in the process of upgrading some code I wrote 2 years ago. I have many instances of the following pattern in my codebase, where I've embedded logic (of various types) directly within the JSX output. Typescript is now complaining that
Type '() => JSX.Element' is not assignable to type 'Element'
. The code continues to work fine, but the TS error really bugs me! What's the solution? I want to minimise the amount of code re-working necessary because it affects so many files. But I also want to maintain the reactivity.
5 Replies
You should probably check out the Show component and refactor the conditional rendering part.
https://docs.solidjs.com/reference/components/show#lessshowgreater
The error comes from the function inside the div which is not called.
Okay. so I guess the equivalent would be
Looks solid 😜
Although „… loading“ should be your fallback right?
yep, true! oops.
For more info read the section about stricter JSX elements: https://github.com/solidjs/solid/releases/tag/v1.7.0
GitHub
Release v1.7.0 - U Can't Type This · solidjs/solid
Solid has experienced incredible growth in usage the past 6 months. Companies are using it to power production applications and SolidStart Beta has been a big part of that. As a natural part of thi...