question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

signals-react doesn't work in react production build

See original GitHub issue

The basic example is not working on production build in react:

const count = useSignal(1);
return (
<div>
   {count}
   <button onClick={() => count.value++}>INC</button>
</div>
);

Versions:

    "@preact/signals-react": "^1.0.2",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",

Building with vite 3.1.0

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:4
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
marvinhagemeistercommented, Sep 28, 2022

This is fixed by the fantastic PR from @jmeistrich #215 🎉 We’ll cut a new release soon.

2reactions
jmeistrichcommented, Sep 27, 2022

@developit No, I don’t think so. I’ve been testing in three different production apps (React 17, 18, React Native) and I don’t see consistent ReactCurrentOwner behavior. In production sometimes it’s set to the root node, sometimes it’s always null (I don’t remember which was which).

But the solution I ended up with was to use only the dispatcher to track lifecycle, mapping to the rerender function rather than the owner, and that is working great. I submitted a PR to use a similar solution for Signals: https://github.com/preactjs/signals/pull/215

Read more comments on GitHub >

github_iconTop Results From Across the Web

@preact/signals-react crashes on production build, at least ...
With react-signals 1.0.2 build for production is now working, but looks like that signals itself is not working at all. At least in...
Read more >
Webpack React build doesn't work on production
I am hosting a production build in a subdirectory of my Apache server. I need that property when making production builds.
Read more >
App works in development but not in production (doesn't build)
I have a react app that runs fine in development (npm start) and doesn't throw any errors. But when I try to build...
Read more >
Optimizing Performance - React
If your project is built with Create React App, run: npm run build. This will create a production build of your app in...
Read more >
How and when to force a React component to re-render
In this demo, I built a clock that has a major problem: the time doesn't change after I first load the screen. Not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found