BUG: useState hook "set" functions break within onUpdate hook (non-React)
See original GitHub issueScope
- This only impacts specific generators/outputs (please list them here): svelte
Describe the bug
When using useState
in your builder or in my project, angular is not rendering the correct code.
To Reproduce Steps to reproduce the behavior:
- Create a useState with get and set.
- OnUpdate call to the setter.
- Angular will generate this code, where
setName
does not exist.
A link to a https://mitosis.builder.io/ fiddle containing the bug:
Expected behavior When using a setter should work.
Additional context I’ve oppened this to talk about angular but I can see the same in all the libraries except with react, is use state only compatible with react??
update: see https://github.com/BuilderIO/mitosis/issues/425#issuecomment-1145644830
Issue Analytics
- State:
- Created a year ago
- Comments:13 (7 by maintainers)
Top Results From Across the Web
Executing async code on update of state with react-hooks
This will render a page refresh, and then use the React Ref in the async function. const stateRef = React.useRef().current const [state,setState] ...
Read more >Steps to Solve Changes Not Reflecting When useState Set ...
What is the useState set method not reflecting a change immediately error? The “useState” hook is one of the in-built hooks in React...
Read more >Understanding common frustrations with React Hooks
useState inside a function. This will throw the error: React hooks must be called in a React function component or a custom React...
Read more >5 Most Common useState Mistakes React Developers Often ...
The useState hook is one of many hooks introduced in React, ... define a state and directly update the state using the set...
Read more >Using the Effect Hook - React
The Effect Hook lets you perform side effects in function components: import React, { useState, useEffect } from 'react'; function Example() { const...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m starting to feel like a QA Engineer 👷♀️
thanks for all your work and responses to all my questions!
the helpers to convert all of those all live in the react generator so we would have to move all of those to helpers and apply them to every framework
updateStateSetters, updateStateSettersInCode, getUseStateCode https://github.com/BuilderIO/mitosis/blob/main/packages/core/src/generators/react.ts