DEV Community

Cover image for Create signals in React with 5 lines of code !

Create signals in React with 5 lines of code !

Mayank on January 13, 2024

Signals are creating a buzz in the frontend ecosystem because of being simple to create, consume and understand. While frameworks like Preact, Qwik...
Collapse
 
brense profile image
Rense Bakker

You can useReducer instead of useState to handle more complex state, but tbh this is not really signals, it's just signals-like syntax around the same react state update that will trigger a traversal of the entire component tree, so child components can decide if they need to rerender. Real signals are more specific than that. The signal should tell the specific components that are using that signal, that they need to rerender.

Collapse
 
mayankhttps profile image
Mayank

Yeah, it's like a syntactic sugar which appears like signals. I hope React implements signals at some point. :)

Collapse
 
pengeszikra profile image
Peter Vivo • Edited

Try the Qwik framework which is based on Proxy solution, plus also use JSX for view building, but use class instead className. Greatest feature is using script fraction, so just the minimal codbase rendered to FE, so it is hughe impact on page loading speed to positive direction.

My opinion the react state-setState solition is give very solid mindset for state handling. So the choice is depend on developer.