Preact: Preact routing doesn't work well with Gatsby

Created on 2 Oct 2019  路  10Comments  路  Source: preactjs/preact

Description

When I click on link (Gatsby Link component), URL in searchbar is changing, but page doesn't change

Steps to reproduce

  • Install Preact (using official plugin instruction)
  • Use a Link component on the page
  • Run build command
  • Click on the link

Expected result

URL changes and new page appears.

Actual result

Page remains, but you'll get a new URL.

Environment

  System:
    OS: Windows 10
    CPU: (4) x64 Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
  Binaries:
    npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD
  Languages:
    Python: 2.7.16
  Browsers:
    Edge: 44.18362.329.0
  npmPackages:
    gatsby: ^2.9.4 => 2.13.50
    gatsby-image: ^2.1.4 => 2.2.8
    gatsby-plugin-feed: ^2.2.3 => 2.3.6
    gatsby-plugin-manifest: ^2.1.1 => 2.2.4
    gatsby-plugin-offline: ^2.1.3 => 2.2.4
    gatsby-plugin-react-helmet: ^3.0.12 => 3.1.2
    gatsby-plugin-sass: ^2.1.0 => 2.1.4
    gatsby-plugin-sharp: ^2.1.5 => 2.2.9
    gatsby-plugin-sitemap: ^2.1.0 => 2.2.5
    gatsby-plugin-twitter: ^2.1.2 => 2.1.2
    gatsby-remark-images: ^3.0.16 => 3.1.7
    gatsby-remark-prismjs: ^3.3.1 => 3.3.4
    gatsby-remark-relative-images: ^0.2.3 => 0.2.3
    gatsby-remark-responsive-iframe: ^2.2.8 => 2.2.8
    gatsby-source-filesystem: ^2.0.39 => 2.1.8
    gatsby-transformer-remark: ^2.5.0 => 2.6.10
    gatsby-transformer-sharp: ^2.1.21 => 2.2.5

All 10 comments

What version of Preact are you using?

Preact X, according to official Gatsby plugin page:

_Note: This plugin uses Preact X, which is currently in beta, since Preact 8 is incompatible with Gatsby v2_

Yes but which version of Preact X, that bug was present in rc.2 and rc.3 but should be resolved in the final.

rc.3. So I need to wait for Gatsby plugin's update or I can manually update Preact?

You can manually update by putting Preact: 10.0.0 in your dependencies

Thanks. Helped!

having the same issue, latest preact, latest gatsby and all 馃し

cc @wardpeet

@persocon are you sure you've updated to latest gatsby & plugin-preact? I know we had an issue with the jsx-runtime check that react and babel had introduced

https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html

@wardpeet HEHEHEHEHEHEHE THAT WORKS!!!! daaaamn life saver :) thanks a lot <3

Was this page helpful?
0 / 5 - 0 ratings