Rebuilding Jotai State Manager for React in 20 Minutes!

Sdílet
Vložit
  • čas přidán 4. 09. 2024

Komentáře • 133

  • @bekirs4240
    @bekirs4240 Před rokem +194

    This type of content is exactly what we need. We don't need more beginner stuff, this is where you learn

  • @MahbuburRahman-uc7np
    @MahbuburRahman-uc7np Před rokem +38

    For a Junior/Mid-level developer, this Content is GOLD. This is the type of content someone like me needs to level up.

    • @ionelLupu_
      @ionelLupu_ Před rokem

      I have 10 years experience of web development and I still find this type of content GOLD 😂

  • @HeinekenLasse
    @HeinekenLasse Před rokem +31

    Amazing! The computed atom part was a bit tough to follow, but that's exactly the type of content we need, something a bit more challenging than the never ending newbie tutorials.

  • @dprophecyguy
    @dprophecyguy Před rokem +22

    Will appreciate more build from scratch videos.

  • @WikiPeoples
    @WikiPeoples Před rokem +15

    This is EXACTLY the content we NEED! No more noobie stuff, but dive into deeper topics like this. LOVE IT!

  • @joshreynolds4164
    @joshreynolds4164 Před rokem +5

    Hands down best channel on youtube right now in the React space. We thank you!

  • @mgrahim5018
    @mgrahim5018 Před rokem +2

    We need more of this. Now, I'll probably have to come back to this video untill I grasp all the concept. Thank you

  • @revillsimon
    @revillsimon Před rokem +3

    Your content keeps getting better, Jack! Fascinating, and I especially like how you explain the reasoning about the types. 😊

  • @rameshramesh-bd2wu
    @rameshramesh-bd2wu Před rokem +1

    Need more videos like this talking about internal function of the system is literally watching a crime thriller movie

  • @WrongAkram
    @WrongAkram Před rokem +2

    You’ve easily become my favorite creator here!

    • @permanar_
      @permanar_ Před rokem

      What? Are you finally remember your YT password?
      You both are my favs content creator bro, I hope you keep that good stuff coming.
      I've been waiting for those another Framer Motion stuff. And maybe some GSAP if possible! Haha.

  • @manny8156
    @manny8156 Před rokem +3

    I’ve learned most of the advanced things in react from you. Thank you so much!

  • @aslamjm
    @aslamjm Před rokem +1

    when i look into youtube webdev tutorial hell all i see are baby level react tutorials with todolist like application. This is the fresh and interesting content most people here need. Thanks Jack keep up the good work

  • @fhucko
    @fhucko Před rokem +4

    I am currently using Zustand in project i work on, but Jotai seems even more simple. I will try to switch to it. Thank you

    • @tawalioualao7444
      @tawalioualao7444 Před rokem +1

      Zustand is more centralized store while Jotai is small store (like react context) so it's depends on your need

    • @rebeccakeller4666
      @rebeccakeller4666 Před rokem

      I'm using both in same project. I much prefer jotai over all (and useReducerAtom sure does blur the line too). But when I thought I'd go all-jotai I got bit by rerenders. With zustand you can use a single properties of a huge single object and subscribers (ie useFooBarStore)only get updates if the selected prop changes. With jotai, all subscribers (even with derived atoms) get pinged.
      That to me is the biggest difference. Still much prefer jotai but as I was basically trying to figure out how to reimplement zustand in jotai I reverted that particular but and use both, preferring jotai as a rule though. There is a jotai library that is supposed to allow you to use sub atoms like that but I couldn't get it working but maybe I'm just dumb idk

    • @fhucko
      @fhucko Před rokem

      @@rebeccakeller4666 I just checked documentation, I think you are supposed to slect part of atom using focusAtom function. Or selectAtom for read only data.

    • @fhucko
      @fhucko Před rokem +1

      @@tawalioualao7444 I use zustand with many decentralized stores using useState. I have also few global stores, but most are scoped in components.

    • @rebeccakeller4666
      @rebeccakeller4666 Před rokem

      @Filip Hučko ah yes thats he library I was thinking of (focusAtom is in another npm package and i cant recall the problems I had exactly). I think actually that selectAtom (which is in jotai primary package) mightve done the trick but I missed the equality operator function as the third parameter - so perhaps there is a cleaner way to do it.

  • @JGBSolutions
    @JGBSolutions Před rokem +2

    I liked it. I gotta watch it more times to get it right. Keep 'em coming.

  • @geralt36
    @geralt36 Před rokem +2

    Ooof that was some fab content Jack. Learned so much. Thanks a ton!

  • @ivanglpz
    @ivanglpz Před rokem +2

    Nice Video about jotai core. I would like to see to daishi kato and Jack Herrington talking about jotai in the future.

  • @karolwons8566
    @karolwons8566 Před rokem +1

    What a great video! I look forward to seeing more advanced stuff like this on your channel.

  • @Echoes2165
    @Echoes2165 Před rokem +1

    Another amazing tutorial. This one might take 2 rewatches and reimplementing it myself before it really clicks in - can't wait!

  • @andrerego2611
    @andrerego2611 Před rokem +2

    That was amazing! I've never seen content like this, thanks!

  • @igboanugwocollins4452
    @igboanugwocollins4452 Před rokem +1

    This is tricky and exciting at the same time! Thank you very much

  • @elmalleable
    @elmalleable Před rokem +1

    jotai will be fun, will solves some promise headaches on a project

  • @Ste00I
    @Ste00I Před rokem +2

    I actually use the sidebar always on the right in VSCode. It just feels more natural to me glancing on the right, instead of on the left.

  • @bosung90
    @bosung90 Před 7 měsíci +1

    Would love to see jotai's onMount as well as jotai-effect

  • @lautarodapin
    @lautarodapin Před rokem +1

    that was so cool! I didn't imagine that it was so simple, like a svelte stoore

  • @awekeningbro1207
    @awekeningbro1207 Před rokem +1

    I really love videos like this. Thanks Jack! This really helps us to understand the core better. Really love to see more videos like this

  • @abhishekvishwakarma9045
    @abhishekvishwakarma9045 Před rokem +1

    Thanks a ton, each video you made is a new learning experience for me , btw I think we can use the `instanceof` operator to check if the return newValue is a Promise object
    like so
    ```
    if (newValue instanceof Promise) {
    // Promise
    } else {
    // not a promise
    }
    ```

  • @umitdemir3741
    @umitdemir3741 Před rokem +1

    You and your contents are really amazigng. Thanks for all of them!

  • @user-qp4fm7ue6y
    @user-qp4fm7ue6y Před rokem

    Your content is really great, And I really like it. This video in particular is exactly what I needed, so I agree with all the other commenters.
    By the way, it is important to note here in a prominent place that the code is not ready as it is, and its actions grow exponentially, very quickly it will cause every key press to millions of actions and the browser to crash, because within the get function you are always subscribing but never unsubscribing, So each run is subscribing again the existing function, which are getting doubled each run. the solution is either to add a key to each atom registration as in the original recoil and then check if it already exists, or use JSON.stringify on the ATOM and check if it already exists using another set.

    • @joshreynolds4164
      @joshreynolds4164 Před rokem +1

      Good point. Could you provide an example of this?

    • @elmalleable
      @elmalleable Před 5 měsíci

      @@joshreynolds4164 learnt that the hard way rebuilding this with rxjs,
      solution is keep a set or map of subscriptions and only subscribe once for the specific atom, add it to the list of subscribed atoms and do not subscribe if a subsciption already exists for it, found that out through simple test cases i made

  • @Fedjz
    @Fedjz Před rokem +1

    What such quality content! Glad to be subscribed to this channel :)

  • @qodesmith520
    @qodesmith520 Před rokem +1

    My man, you got the like, subscribe, AND I rang the bell. This was amazing.

  • @bartek...
    @bartek... Před rokem +2

    Thanks for your work. Another very valuable video.

  • @rkrupinski
    @rkrupinski Před rokem

    Great video, Jack! I think I see a subtle bug in the implementation though. Looks like we're continuously re-subscribing (in the `get` function), which makes the number of subscriptions grow exponentially.

  • @realbigsquid
    @realbigsquid Před rokem +1

    100 percent mind blown

  • @deamorta6117
    @deamorta6117 Před rokem +1

    GOLD GOLD GOLD content

  • @petrhavlik
    @petrhavlik Před rokem +1

    Excellent stuff Jack, please keep going!

  • @Dgiulian
    @Dgiulian Před rokem +1

    I loved the video. Keep making this content. This is pure gold

  • @dhaw
    @dhaw Před rokem +1

    just amazing !!!

  • @feitan8745
    @feitan8745 Před rokem +2

    Impressive as always, currently i'm using custom reducers for my apps and the setup is quite the same.

  • @erikslorenz
    @erikslorenz Před rokem +1

    I've been loving Jotai thanks Jack

  • @Dev-Coder
    @Dev-Coder Před rokem +1

    Amazing content!❤️

  • @user-jb9wp9vf3h
    @user-jb9wp9vf3h Před 7 měsíci +1

    Enjoyed your video, thank you.💯

  • @gencomer
    @gencomer Před rokem +1

    Very impressive

  • @awekeningbro1207
    @awekeningbro1207 Před 6 měsíci

    14:48 I think there a memory leak issue in the get function because everytime salary or bonus changes, it will keep stacking new subscriber function, I think we need to call unsubscribe function inside the subscribe callback in order to fix that

  • @andrepadez
    @andrepadez Před rokem +3

    you're a GOD among men

  • @CrazyWolf132
    @CrazyWolf132 Před rokem +2

    It would be super cool if you could do the same kind of video for creating a system like `react-hook-form`.

  • @vcothur7
    @vcothur7 Před rokem +2

    This is amazing!

  • @thiagomoraes791
    @thiagomoraes791 Před rokem +2

    great content 😀

  • @MsPrakhar12
    @MsPrakhar12 Před rokem +1

    pretty awesome 🔥 Amazing work

  • @kasvith
    @kasvith Před rokem +1

    Great stuff as always

  • @tolgask2812
    @tolgask2812 Před rokem +1

    wonderful content :D

  • @streamoverlayprocodes6890

    aha! I see you doing semantic names for type definitions on generics! someone is watching Matt Pocock

  • @jeresalem
    @jeresalem Před rokem +1

    Awesome.

  • @vasilicampuica6428
    @vasilicampuica6428 Před rokem +1

    Great content, Jack!

  • @eliasimokhai
    @eliasimokhai Před rokem +1

    This was tough and fun

  • @luizpaulonascimento9162
    @luizpaulonascimento9162 Před rokem +1

    awesome content

  • @download333
    @download333 Před rokem

    One little hair change and my man looking like the mayor of Pleasantville

  • @jamshediqbal7936
    @jamshediqbal7936 Před rokem +1

    Good channel to learn advanced topics 🎉

  • @vonderklaas
    @vonderklaas Před rokem

    Thanks Jack, captivating as always!

  • @samsurya283
    @samsurya283 Před rokem +1

    Awesome, could you please make a video on two way binding

  • @mdjaman7348
    @mdjaman7348 Před rokem +1

    love you bro

  • @thecodecatalyst
    @thecodecatalyst Před rokem +1

    File tree on the right is the way

  • @parassharma7041
    @parassharma7041 Před rokem +2

    A scientist keeps experimenting with react 😃

  • @saiyanrivals
    @saiyanrivals Před rokem +1

    Awesome

  • @lilpodbebe
    @lilpodbebe Před rokem +1

    Pure gold!

  • @greatauntmuriel
    @greatauntmuriel Před rokem +1

    explorer on the right is superior

  • @ToreyLittlefield
    @ToreyLittlefield Před rokem +2

    Challenge accepted 🔥🔥

  • @kerodfresenbetgebremedhin1881

    Sir, you are the best fit for intermediate to high skill programming content. I have no right to impose upon you content restrictions, but in my opinion you and obviously content consumers like me would be best served in this niche.

    • @jherr
      @jherr  Před rokem

      Don't worry, I'll always be producing some medium to advanced content on a regular basis.

  • @fricze
    @fricze Před rokem +1

    cool stuff

  • @user-pw4oq9cs3l
    @user-pw4oq9cs3l Před 8 měsíci +1

    amazing video, thank you !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • @shivamjhaa
    @shivamjhaa Před rokem +1

    This is really really cooool!

  • @Shifter21000
    @Shifter21000 Před rokem

    This is a great help, Jack. How does Jotai and state management work together with SSR in NextJS. There are few hooks for this need, some go with providers, but is there an established pattern here.

    • @jherr
      @jherr  Před rokem

      If you have global atoms it's pretty easy. I haven't checked with Jotai's contextual stuff, probably still works. Basically any state manager that has external (non-hook) access is going to work with RSCs.

  • @MouseCodes
    @MouseCodes Před rokem +2

    hey jack nice content, I hope you make a video about how to make a profile for users and enable them to update their info with zustand and nextjs protected routes. this would be really helpful.

    • @jherr
      @jherr  Před rokem +1

      That seems awfully specific. Is that what you are working on currently?

    • @MouseCodes
      @MouseCodes Před rokem

      Yeah and CZcams has nothing like that most tuts only scratch the surface of zustand which makes it hard to use this un-opinionated library.

    • @MouseCodes
      @MouseCodes Před rokem

      It's specific but it is needed for every project whether it is e-commerce, freelancing site, social media, etc...

    • @jherr
      @jherr  Před rokem +1

      @@MouseCodes No worries. And you're right, auth is needed for pretty much every site. Have you tried NextAuth? Generally I let that manage the user and then on the profile page I would get the profile data during SSR and preload react-query with the profile information, then use RQ later to update it through an authorized API route.

    • @MouseCodes
      @MouseCodes Před rokem

      That's exactly what I am trying to achieve, that solution was definitely inspired by your videos.

  • @charliematters
    @charliematters Před rokem +1

    That was great and really easy to follow. Is that copilot doing all the magical autocompletion?

    • @jherr
      @jherr  Před rokem +1

      Yep. With a serious helping of me since that was the second time around so Copilot was repeating a lot of my back to myself. :)

    • @charliematters
      @charliematters Před rokem

      @@jherr I did think it was even cleverer than I expected!

  • @pollettoimpanato
    @pollettoimpanato Před rokem +1

    18:35 my honest reaction every time “unexpected { at line 189” disappears after a random reload (there are only 10 lines of code)

  • @streamoverlayprocodes6890

    the code explorer to be on the right feels a bit unnatural because our romantic language disposition is to look from left to right, and when I look for files, my brain maps everything from the left. But everything is about user preferences 😀, I won't mandate you to eat soup with a fork :)

  • @GachiTscho
    @GachiTscho Před rokem +1

    This should go to Jotai official docs🤣

  • @bradleyangusmorgan7005
    @bradleyangusmorgan7005 Před 10 měsíci

    🎯 Key Takeaways for quick navigation:
    00:00 🚀 Jotai is introduced as an atomic state manager for React, similar to Recoil, and the video begins with a challenge to rebuild it.
    01:09 🧩 Demonstrates how atoms in Jotai can be any data type and used throughout a React application, providing a global state.
    03:15 🔧 The structure of an atom is outlined, including methods for getting, setting, and subscribing to changes in its value.
    05:17 🎣 Explains the creation of the `useAtom` hook in Jotai, which integrates the atom with React's state management.
    08:00 ✨ Showcases the use of the `useSyncExternalStore` hook to simplify state synchronization within the React ecosystem.
    09:36 🌐 Jotai allows for the creation of global data that is easily accessible throughout the component hierarchy and is simple to implement.
    10:35 ➕ The 'total salary atom' in Jotai can calculate derived state, such as summing a salary and a bonus, using getter functions to access other atoms' values.
    12:05 🔄 Jotai's atom types can be dynamic, meaning an atom can be a function that computes its value based on other atoms, and TypeScript can be used to ensure type correctness.
    14:10 🔄 The video demonstrates how to ensure atoms re-compute their values when dependencies change and how to avoid unnecessary computations.
    15:44 ⏳ Jotai supports asynchronous atoms, which can perform operations like data fetching and automatically handle promise resolution.
    Made with HARPA AI

  • @jr-hp7er
    @jr-hp7er Před rokem

    This is awesome. I love this. This is precisely what is needed. I have 1 question where I want to implement a Modal window with the form elements, and when I close the window and re-open it again, I want to display data selected by the users previously. Can this help or do we require some sort of persistence here?
    I have tried with redux, wrapping the parent component above the modal, and it works fine? But want to move from redux to something like this

    • @jherr
      @jherr  Před rokem +1

      I would strongly recommend going with Jotai instead of using this code. This code was presented as a way to more deeply understand how this one particular model of state management works, not to actually replace Jotai.
      TBH, any state manager, including Redux, will handle the scenario you present. I recommend pushing on with redux. Use the redux toolkit if you aren't already. And if you get stuck on modeling then this then ask for assistance on Reactiflux, but make sure to follow their rules before posting.

    • @jr-hp7er
      @jr-hp7er Před rokem

      @@jherr Thank you so much 🙏

  • @jasondavis87
    @jasondavis87 Před rokem +1

    I love this!!!

  • @rodneydin
    @rodneydin Před rokem +1

    Would it be great if you had a discord server 🎉

    • @jherr
      @jherr  Před rokem +1

      Turns out, I do: discord.gg/sae4SWPAFN

  • @michaelscofield2469
    @michaelscofield2469 Před rokem +1

    Please make a video about how to setup react, typescript, eslint, prettier

  • @aliarslanansari
    @aliarslanansari Před rokem

    In a follow up video, can you write test for this code using JEST or any of your preferred testing library?

  • @WajuAbolarin
    @WajuAbolarin Před rokem +1

    This is amazing content. and to get this for free. thanks Jack!

  • @frontend_ko
    @frontend_ko Před rokem +1

    Zustand is the next, sir?

  • @adityapanday007
    @adityapanday007 Před rokem +1

    Which extension used for auto suggestions?

    • @jherr
      @jherr  Před rokem

      GitHub Copilot

  • @ayushjain7023
    @ayushjain7023 Před rokem

    Hey Jack, do we need to have atom dependency inside useEffect?

  • @Maybehassanawad
    @Maybehassanawad Před rokem +1

    Can you please rebuild Valtio🤩

    • @jherr
      @jherr  Před rokem

      At it's most basic I can (and will) do that as a short.

  • @thomashermant9321
    @thomashermant9321 Před rokem

    Hi !
    First of all you do a great job on your content !
    I try you code in my NextJs application.
    Everything working fine until I use an atom with a getter function.
    My Set reached is maximum capacity.
    When I put a log between line 23 and 24 in jotai.ts
    After some inputs manipulation I got thousand even million logs.
    Any idea to improve it ?

    • @Seedzification
      @Seedzification Před rokem

      yea it's probably missing a useref or a usecallback somewhere?

  • @andrewc8125
    @andrewc8125 Před rokem +1

    I think it is time to migrate from Recoil to Jotai

  • @adamjamiu6764
    @adamjamiu6764 Před rokem

    Hi Jack 😊. What is the name of your code editor font family

    • @jherr
      @jherr  Před rokem

      JETBrains Mono

  • @codingleo
    @codingleo Před rokem +2

    First here woooooohoooo

  • @VKD007
    @VKD007 Před rokem +1

    I thought you will use signals and jotai

    • @jherr
      @jherr  Před rokem +2

      I made this video before the "great signal boom of early 2023" :) But I wouldn't have added them anyway, since I really don't think ref-patching React is a good idea.

    • @VKD007
      @VKD007 Před rokem

      I really liked jotai though, ive seen your video. Jotai for async state and signals for granular updates.

  • @ak-loz
    @ak-loz Před rokem +1

    :[[
    Eventually I will understand this.

  • @DjLeonSKennedy
    @DjLeonSKennedy Před rokem +1

    You need to create payable courses, your explanation is perfect!

  • @_RobTheRed_
    @_RobTheRed_ Před rokem

    Next for UI/UX with rebuild/refresh of react drag n drop? 🫣

  • @MohamedElmardi123
    @MohamedElmardi123 Před rokem +1

    Amazing!