DEV Community

Cover image for Redux in one line...
Chad Steele
Chad Steele

Posted on

Redux in one line...

What if I told you that you could replace Redux with one line of code? What if I told you it was as easy as using useState and works just like it, except it's shared and does not depend on Redux, Context, or any other library?

What if I told you it was high performant and less than 3k?

    import {useSync} from 'ez-sync-js'

    const [myVar, setVar] = useSync('myVar','optional initial value')
Enter fullscreen mode Exit fullscreen mode

See the demo

Click [more] when you get there and add as many React components as you like, they instantly share state.

But seriously, why are you still reading this post... git'r done

npm

It's called ez-sync-js
https://www.npmjs.com/package/ez-sync-js

git

https://github.com/chadsteele/sync

Latest comments (4)

Collapse
 
chadsteele profile image
Chad Steele

@brense I'd love your expert critique of my solution to Redux. :)

Collapse
 
brense profile image
Rense Bakker

Its not really a replacement for something like redux. There are a lot of different state management solutions for react. If you want a solution that has less (redux) boilerplate, have a look at jotai

Collapse
 
selbekk profile image
selbekk

Cool idea!

It doesn't support middleware or async actions, though, and why wouldn't you want to use context anyways?

Collapse
 
chadsteele profile image
Chad Steele

Please clarify why you think it doesn't support middleware or async actions? I don't use context because it get's heavy fast, native events are light, proven, fast, and intuitive.