Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug - v1.3.x Throws Errors when Used in React #350

Closed
TheGreatAxios opened this issue Apr 16, 2023 · 5 comments · Fixed by #355
Closed

Bug - v1.3.x Throws Errors when Used in React #350

TheGreatAxios opened this issue Apr 16, 2023 · 5 comments · Fixed by #355
Assignees

Comments

@TheGreatAxios
Copy link

Overview

Began using v1.2.2 ~3 weeks ago and it worked whether using new Signal() or signal outside of react component, or when using useSignal() within a component. Started a new project and automatically picked up v1.3.1. As soon as I began implementing signals, the app immediately broke.

Packages (using remix.run + React)

Remix.run - 1.1.15
Node.js - v18.12.0

The error thrown is:

throw new Error('Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for' + ' one of the following reasons:\n' + '1. You might have mismatching versions of React and the renderer (such as React DOM)\n' + '2. You might be breaking the Rules of Hooks\n' + '3. You might have more than one copy of React in the same app\n' + 'See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.');
          ^
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.

There are also some other things related to goroutines and esbuild errors that throw:

fatal error: all goroutines are asleep - deadlock!

goroutine 1 [chan receive]:
github.com/evanw/esbuild/internal/helpers.(*ThreadSafeWaitGroup).Wait(...)
        github.com/evanw/esbuild/internal/helpers/waitgroup.go:36
main.runService.func2()
        github.com/evanw/esbuild/cmd/esbuild/service.go:127 +0x59
main.runService(0x1)
        github.com/evanw/esbuild/cmd/esbuild/service.go:181 +0x530
main.main()
        github.com/evanw/esbuild/cmd/esbuild/main.go:228 +0x21c

goroutine 34 [chan receive]:
main.runService.func1()
        github.com/evanw/esbuild/cmd/esbuild/service.go:111 +0x3e
created by main.runService
        github.com/evanw/esbuild/cmd/esbuild/service.go:109 +0x1e5

goroutine 35 [chan receive]:
main.(*serviceType).sendRequest(0xc00010dd40, {0x14a91c0, 0xc001c692c0})
        github.com/evanw/esbuild/cmd/esbuild/service.go:210 +0x110
main.runService.func3()
        github.com/evanw/esbuild/cmd/esbuild/service.go:138 +0x39
created by main.runService
        github.com/evanw/esbuild/cmd/esbuild/service.go:135 +0x353

Temporary Solution

Rollback to v1.2.2.

@JacquesDoubell
Copy link

I'm also getting errors. I got the above and also TypeError: Cannot read properties of undefined (reading 'next')

@XantreDev
Copy link
Contributor

Please add reproduction

@TheGreatAxios
Copy link
Author

@XantreGodlike to preproduce:

  1. Create Remix App
npx create-remix@latest
  1. Add @preact/signals-react
npm add @preact/signals-react
  1. Add a signal in the application whether in or out of state and the app will just continue to break and throw errors. I tested the hook (useSignal) as well as creating them outside of state (this is what I am actually doing i.e new Signal(xxx) or signal(xxx) and everything throws an error

@andrewiggins
Copy link
Member

I'm working on fixes for this. More coming soon

@andrewiggins andrewiggins self-assigned this Apr 18, 2023
@XantreDev
Copy link
Contributor

XantreDev commented Apr 19, 2023

btw there are issues with react-native #346 i will try to add good repro too. I think this issues can be related

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants