Loading video...

Video Failed to Load

Go Home

I made a state management library for React. It's called simple store. Goal: make Zustand way simpler ⭐ - Stores are like atom() in Jotai, so types are inferred - You can select nested values, and use *them* as stores too To understand that last point, watch to the...

79,936 views • 11 months ago •via X (Twitter)

35 Comments

Ben Holmes's profile picture
Ben Holmes11 months ago

I have a full breakdown on YouTube!

Ben Holmes's profile picture
Ben Holmes11 months ago

The source:

Kevin Marques's profile picture
Kevin Marques11 months ago

We don't need "simple" state manager. They already are simple, because it's just a reducer. Wtf is this trend from some developers to always search for "simple" solutions, when the world need expertise, robust and strong software ?

qwertea's profile picture
qwertea11 months ago

Really nice, would be great if getting deeply nested values didn’t require a chain of selects though but rather a way to use one select with an object or comma separated strings maybe

Ben Holmes's profile picture
Ben Holmes11 months ago

We're tracking an issue for this right now! If we support this, I believe we'll use Zustand's arrow function syntax as an alternative. Ex. select(store => store.deeply.nested.value)

Name cannot be blank's profile picture
Name cannot be blank11 months ago

Or use Solid with signals.

zenith's profile picture
zenith11 months ago

I really love your approach on this. thanks for building and sharing.

promethean's profile picture
promethean11 months ago

If I may, subscribe returning a tuple of current value and unsubscribe might save people a bit of effort

json™️'s profile picture
json™️11 months ago

thank you for the tutorial @code_cowboy cc @kevfaveri

Sp Loff's profile picture
Sp Loff11 months ago

But why? Aren't there already a tons of state management solutions?

Paul van Dyk's profile picture
Paul van Dyk11 months ago

What happens if you have side effects, e.g., `meta: { contentLength: number }` which is the length of the `content` store value? Is there any way to handle those types of effects?

Ben Holmes's profile picture
Ben Holmes11 months ago

That sounds like derived values. I'd suggest generating those in your component instead of putting on the store directly. You can also hack it using subscribe: =>

Tony OHagan's profile picture
Tony OHagan11 months ago

Just walk over to Vue and use Pinia stores and all this subscribe complexity disappears. MVVM is so much simpler with right reactivity model.

Muhammad Mejanul Haque's profile picture
Muhammad Mejanul Haque11 months ago

I honestly don't get why people use zustand instead of jotai. some people just blindly follows other devs. you are using a library to write less code, not to write the same amounts of code. this is not a redux era.

Pavitra Golchha's profile picture
Pavitra Golchha11 months ago

this is nanostores

Kerem Atam's profile picture
Kerem Atam11 months ago

I like this work but if the selling point of this is being simple, then I think the only thing that really needs fixing in Zustand is type inference. Anything beyond that doesnt add simplicity, it just forces new patterns onto devs (which is fine, but i would nto call it "simple" anymore).

Eduardo Alvarez's profile picture
Eduardo Alvarez11 months ago

Does it have a website? That’s how I judge state management tools. Redux review is… designed with Bootstrap 4. Zustand, that one is good!

Niall O'Brien's profile picture
Niall O'Brien11 months ago

Looks neat, does it also support hydration for SSR much like Jotai?

Verious B. Smith III's profile picture
Verious B. Smith III11 months ago

That's nice

Kirill Rodionov's profile picture
Kirill Rodionov11 months ago

Valtio solved this… go check it out it’s goated

Stephen Burke's profile picture
Stephen Burke11 months ago

Nicely done sir 🫡

Tom Firth's profile picture
Tom Firth11 months ago

This looks great. > You can select nested values, and use *them* as stores too Sounds hot, how does that compare to jotai + optics? That said, we all know that Daishi has a monopoly on state management these days. He may come for you.

Seb ⚛️ ThisWeekInReact.com's profile picture
Seb ⚛️ ThisWeekInReact.com11 months ago

I like this kind of abstraction Just wondering if it's not possible to build it on top of Zustand? I remember some lens/optics plugins/middleware in the past

Carlos Rico-Ospina's profile picture
Carlos Rico-Ospina11 months ago

I just hash and put the entire client state in the URL params. What’s the issue

Michael Magán's profile picture
Michael Magán11 months ago

congrats on the launch

Asdrúbal Chirinos (Astro) 🚀's profile picture
Asdrúbal Chirinos (Astro) 🚀11 months ago

You've got my attention.

David K 🎹's profile picture
David K 🎹11 months ago

This is basically the latest XState Store (Zustand + Jotai)

Webiny Enterprise CMS+ ⚡️'s profile picture
Webiny Enterprise CMS+ ⚡️11 months ago

Cool concept! Love the simplicity angle.

Sandrin Joy's profile picture
Sandrin Joy11 months ago

😍

Matthew Volonnino's profile picture
Matthew Volonnino11 months ago

Also something I think would be great DX that Zustand has, is updating parts of the store without needing to spread the store and would only update that specific part of store (keeping re renders optimized): const store = { foo: “bar”, bar: “baz” } store.set({bar: “z”})

Karan Jagtiani's profile picture
Karan Jagtiani11 months ago

Does your simple store support middleware like persistence or logging out of the box?

Omar Shoura's profile picture
Omar Shoura11 months ago

This is really neat. Feels pretty simple

Leszek's profile picture
Leszek11 months ago

How many levels deep we are on abstractions ?

Jacob Kelley's profile picture
Jacob Kelley11 months ago

This is dope!

Robert 🟠's profile picture
Robert 🟠11 months ago

what happened to lazyvim?🤣

Related Videos

Did you know if you tried to open a Trader Joe's, Grocery Outlet, or soon even a Mollie Stone's in San Francisco - you can't? That's because SF has a rule that formula retail chain stores that have more than 11 stores (worldwide!) can not open in commercial districts without a conditional use permit. With grocery stores and pharmacies closing across our city, these permits can delay opening new stores by 6-9 months - delaying much needed affordable food in our neighborhoods. So today I announced legislation to fix it. Going forward, any parcel already designated as a formula retail chain can convert to a grocery store or pharmacy without an additional conditional use permit. This will save them months on opening. For any new grocery store that opens, we will also allow them to include a bank, pharmacy, or restaurant without the need for another conditional use permit. As grocery stores consolidate and get smaller, this will help them occupy larger spaces while also bring more needed services to neighborhoods in need. And lastly, we will add grocery stores and pharmacies to the city's priority processing list. Importantly, this legislation isn't going to change the character of your neighborhood. It only regulates parcels that are already designated for formula retail chains. Because amidst an affordability crisis restricting access to food and medicine, we need to make it easier to open needed services. Not bury them in red tape. Thank you Supervisors Sherrill and Melgar for your early cosponsorship of our legislation. We will introduce it at the Board of Supervisors in the weeks ahead, and expect it to pass before the end of the year.

Bilal Mahmood 馬百樂

54,921 views • 1 month ago

Today I announced the Affordable Groceries Act to address our growing affordability crisis in San Francisco. For years, the price of milk, fresh vegetables, and more has been rising by double digits. At the same time, large chain corporations are leaving grocery stores and pharmacies as "zombie stores" - paying their lease to keep the storefronts vacant and block competition. The Affordable Groceries Act aims to end those food deserts by providing stimulus incentives to new grocery stores and pharmacies, while taxing zombie stores to generate revenue that could be used to fund new stores that sell affordable, fresh food. It works in 3 steps: 1. Streamline new stores, by eliminating conditional use permits for new groceries and pharmacies on vacant lots, while providing tax credits to reduce pharmacy gross receipts taxes. 2. Tax zombie stores, by ensuring that large chain corporations that deliberately leave grocery stores and pharmacies empty pay a vacancy tax for as long as they block competition from using the storefronts. The tax would not apply to small businesses, or to any new store that opens after January 2027. 3. Fund affordable groceries, by establishing an Affordable Grocery Fund that will subsidize operators that provide fresh affordable food. This could help corners stores convert into full grocery stores with fresh food, or let the city purchase buildings and rent them out to grocery operators who agree to keep prices low. We're bringing Affordable Groceries Act to the ballot this November, so you can make your voices heard that every San Franciscan deserves fresh affordable food in their neighborhood.

Bilal Mahmood 馬百樂

13,695 views • 4 months ago

Friedberg Predicts NYC’s Socialist Grocery Stores Will Be Wildly Popular and a DSA Marketing Tool for 2028 david friedberg: “I think that people have it wrong. I think these grocery stores are going to be wildly popular. I think that everyone's being a little bit too long-sighted in their view on what's going to happen with these grocery stores, with the basic obvious economic arithmetic that someone has to pay for this, and who's going to pay for it, and blah, blah, blah. I don't think it really matters because over the near term, what the cheap grocery stores do is create an incredible success story for socialism that will help to support and fuel the socialist wave in urban centers around this country. Think about the social network effect of the grocery store. So there's a couple of them, and then people start traveling from far away to the cheap grocery store because it has this discount. Again, this'll play out over the next 24 months, going into the 2028 election cycle, and everyone's like, ‘This is so wildly popular. People are coming in from all over the place to go to these grocery stores.’ They're not checking IDs, because IDs are racist, and you can't check IDs to vote, so we shouldn't be able to check IDs for grocery stores. So people will come in from all over the place to use these grocery stores. The demand will go up. And then they'll start to open more and more grocery stores like this. And let's say each one loses $10 million/year and they get to 10 or 20 of these. That's $200 million of losses/year on the grocery store chain. But it creates this extraordinary social movement for more of these grocery stores supporting the DSA and so on. $200 million/year on a $125 billion/year budget for the city of New York is nothing. It's less than a quarter of a percent of the city's budget. That is so cheap to market the DSA platform, and to get the DSA platform to become a social marketing element that drives the next wave here. So again, I do think that these grocery stores, believe it or not, they sound silly, they sound small, but I predict that they will be deemed a point of success, and they will end up being a big part of the fuel for the DSA going into 2028.”

The All-In Podcast

128,150 views • 3 months ago