Compatiblity of PreactX alpha 0 with Preact.Router
See original GitHub issueI just tried to migrate my Preact app to Preact X, but it’s crashing when it’s starting. Should it run with the Preact router, or is there any known incompatibility?
util.js:69 Uncaught TypeError: Cannot read property 'replace' of undefined
at segmentize (util.js:69)
at rank (util.js:77)
at rankChild (util.js:81)
at prepareVNodeForRanking (util.js:64)
at Array.filter (<anonymous>)
at Router.getMatchingChildren (index.js:213)
at Router.render (index.js:231)
at _ (index.js:126)
at _ (index.js:137)
at d (children.js:74)
I use Preact together with Parcel.js for module bundling and with the previous version it was running perfectly.
After the migration I just removed the third parameter from the render function
render(<App />, document.body)
Instead of using document.body I also tried to use a div inside of the body as root element, but I got the same error as before. I use preact-router in the latest version 2.6.1 and preact-compat v3.18.4
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Preact-router - npm.io
Note: This is not a preact-compatible version of React Router. preact-router is a simple URL wiring and does no orchestration for you.
Read more >How to use React Router with Preact - Stack Overflow
I'm not sure if it's a compatibility problem, or a configuration problem. I've tried using just one pair of routes ( App and...
Read more >reznord - npm
preact. Fast 3kb React-compatible Virtual DOM library. marvinhagemeister ... Render JSX to an HTML string, with support for Preact components.
Read more >React Router v6 Preview
react -router-dom@6.0.0-alpha.2 reveals the total bundle size decreased by 70%. Smaller bundles means your app loads more quickly, especially ...
Read more >Switching to Preact (from React)
preact/compat is our compatibility layer that allows you to leverage the many libraries of the React ecosystem and use them with Preact.
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 FreeTop 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
Top GitHub Comments
I just invested a bit more time now to investigate the problem and I found out, that the problem was in my code in the Router.onChange eventhandler. In the previous version I read e.current.attributes, but it seem that this is no longer working. So instead it’s now e.current.props.
I looked into the last commits of the preact router, and I found where it was changed:
https://github.com/developit/preact-router/commit/ebbda180a8b8db2d42489cfb1d05ba79a74c15ca#diff-34a6d62af0cf0b784f8444529f3130efR65
After I fixed it, Preact X is now running with my project. Thanks to all contributors to provide us all the new features. Especially React.Fragment and also the Hooks I missed very much.
Preact X doesn’t use
preact-compat
anymore instead Preact X ships a compat layer inpreact/compat
. There is already a WIP PR for updating preact-router developit/preact-router#298Updating
preact-render-to-string
shouldn’t be that much of a hassle. I might give it a try later if no one has created a PR for it by then.