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

Selecting a component with a signal hook breaks the signal. #456

Closed
MicahZoltu opened this issue Feb 5, 2023 · 1 comment · Fixed by #460
Closed

Selecting a component with a signal hook breaks the signal. #456

MicahZoltu opened this issue Feb 5, 2023 · 1 comment · Fixed by #460

Comments

@MicahZoltu
Copy link
Contributor

export function App() {
	const apple = useSignal(0)
	return <main>
		<div>{apple}</div>
		<button onClick={() => apple.value += 1}>Increment</button>
	</main>
}
  1. Install Preact DevTools into Brave (I haven't tested other browsers).
  2. Run the above app.
  3. Open Preact dev tools.
  4. Select the App component in the Elements tab.
  5. Notice that you can see the useSignal hook in the sidebar.
  6. Click the Increment button in the app.
  7. Notice that the counter doesn't increase.
  8. Click on the App component in the Elements tab again.
  9. Notice that the counter incremented.
  10. Notice that the useSignal hook no longer shows up in the side bar.
  11. Click the Increment button again.
  12. Notice an error in the console TypeError: t.setState is not a function
Uncaught TypeError: t.setState is not a function
    at r.c (index.ts:149:15)
    at t (index.ts:63:13)
    at e.set (index.ts:321:5)
    at Object.onClick [as clickfalse] (App.tsx:24:37)
    at HTMLButtonElement.I (props.js:150:27)
@MicahZoltu
Copy link
Contributor Author

I'm guessing that the act of clicking on the component in the Elements tab of Preact dev tools results in a hook being installed into the Signal, and that hook installation is somehow broken. I spent some time trying to debug the issue, but since the debug tools source code is minified it is quite difficult.

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.

1 participant