Using signals package with react router results in a wierd jsx error
See original GitHub issueI tried using @preact/signals-react
in a project with react-router 6 but I got that error which doesn’t make any sense to me, the error is complaining about react-router but originates from @preact/signals-react
and only happens when I import/use anything from @preact/signals-react

here is a link https://stackblitz.com/edit/react-router-starter-gfxkdm?file=components%2FHome.js to reproduce the error, try commenting out the signal import/usage in Home.js and everything will work fine
I think it could be related to the patches to JSX factories, which breaks the react-router check for the <Route/>
element type somehow, if I used it with the routing config approach from react-router 6.4 it works fine
Issue Analytics
- State:
- Created a year ago
- Reactions:4
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Issues · preactjs/signals - GitHub
Contribute to preactjs/signals development by creating an account on GitHub. ... Using signals package with react router results in a wierd jsx error...
Read more >Error: Router cannot be used as a jsx component
reactjs - Error: Router cannot be used as a jsx component - Stack Overflow. Stack Overflow for Teams – Start collaborating and sharing ......
Read more >React Router DOM: How to handle routing in web apps
React Router DOM contains the DOM bindings for React Router. Learn about its essential components and how to build routes with parameters.
Read more >Documentation - SolidJS · Reactive Javascript Library
A declarative, efficient and flexible JavaScript library for building user interfaces.
Read more >Fixing the 'cannot GET /URL' error on refresh with React ...
In this post you'll learn how to fix the 'cannot GET /URL' error with React Router. Along the way, you'll also learn how...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@lennerd the fix may be to go back to injecting updaters into components via react internals rather than wrapping all components. I’ve been using and testing a local version of that approach this week, and it’s working in dev and prod builds using React Router 6.4.
couldn’t find a workaround for this error so I had to use the
@preact/signals-core
package with this custom hookthat allowed me to update the signals from anywhere and then where I use that hook react will rerender because of the local state update
it is not the best/optimal solution but hopefully, this issue with react-router could be fixed