Preact: Reach Router not working with Preact X

Created on 24 Sep 2019  路  6Comments  路  Source: preactjs/preact

I've been looking to use Reach Router on my project, however it appears that it's not compatible with Preact.

I believe the issue is that the props created by Reach Router are not being passed down to the components and not causing a re-render as expected.

The URL updates so the History API part seems to be okay. The problem seems to be more related to the preact compat not handling the props appropriately. This is working fine with React.

Please see the examples below.

Reach Router with React

Reach Router with Preact

Most helpful comment

@montyx99 preact-compat is for preact 8, use preact/compat for preact 10 instead

All 6 comments

Hey @CedarDCX

This issue will be resolved when the new version of Preact will be released, this is an issue with our context Consumer bailing out of rerendering. You'll see that this is working with previous rc versions (tried with rc.1).

That's great, thank you for your help @JoviDeCroock . I can confirm it works with rc.1.

Closing this ticket.

@CedarDCX how did you make it work?
Could not find dependency: 'preact-compat' relative to '/node_modules/@reach/router/index.js'
I always got this ^^^ error, when I try to use the 10.1
https://codesandbox.io/s/blissful-hertz-yz75i?fontsize=14&hidenavigation=1&theme=dark

@montyx99 preact-compat is for preact 8, use preact/compat for preact 10 instead

Thanks a lot, I'm going to test is. Honestly I've never noticed before that there is a / sign instead of a -. I'm so sorry for that.

There might be an issue with the codesandbox preact-cli template

Was this page helpful?
0 / 5 - 0 ratings

Related issues

skaraman picture skaraman  路  3Comments

kay-is picture kay-is  路  3Comments

nopantsmonkey picture nopantsmonkey  路  3Comments

matuscongrady picture matuscongrady  路  3Comments

marcosguti picture marcosguti  路  3Comments