Rebuilding Jotai State Manager for React in 20 Minutes!

Поділитися
Вставка
  • Опубліковано 25 сер 2024

КОМЕНТАРІ • 133

  • @bekirs4240
    @bekirs4240 Рік тому +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 Рік тому +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_ Рік тому

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

  • @HeinekenLasse
    @HeinekenLasse Рік тому +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.

  • @WikiPeoples
    @WikiPeoples Рік тому +15

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

  • @dprophecyguy
    @dprophecyguy Рік тому +22

    Will appreciate more build from scratch videos.

  • @joshreynolds4164
    @joshreynolds4164 Рік тому +5

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

  • @mgrahim5018
    @mgrahim5018 Рік тому +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 Рік тому +3

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

  • @elmalleable
    @elmalleable Рік тому +1

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

  • @manny8156
    @manny8156 Рік тому +3

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

  • @rameshramesh-bd2wu
    @rameshramesh-bd2wu Рік тому +1

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

  • @geralt36
    @geralt36 Рік тому +2

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

  • @JGBSolutions
    @JGBSolutions Рік тому +2

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

  • @karolwons8566
    @karolwons8566 Рік тому +1

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

  • @aslamjm
    @aslamjm Рік тому +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

  • @andrerego2611
    @andrerego2611 Рік тому +2

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

  • @ivanglpz
    @ivanglpz Рік тому +2

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

  • @igboanugwocollins4452
    @igboanugwocollins4452 Рік тому +1

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

  • @Echoes2165
    @Echoes2165 Рік тому +1

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

  • @awekeningbro1207
    @awekeningbro1207 Рік тому +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

  • @umitdemir3741
    @umitdemir3741 Рік тому +1

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

  • @WrongAkram
    @WrongAkram Рік тому +2

    You’ve easily become my favorite creator here!

    • @permanar_
      @permanar_ Рік тому

      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.

  • @dhaw
    @dhaw Рік тому +1

    just amazing !!!

  • @Dev-Coder
    @Dev-Coder Рік тому +1

    Amazing content!❤️

  • @bosung90
    @bosung90 7 місяців тому +1

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

  • @fhucko
    @fhucko Рік тому +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 Рік тому +1

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

    • @rebeccakeller4666
      @rebeccakeller4666 Рік тому

      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 Рік тому

      @@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 Рік тому +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 Рік тому

      @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.

  • @user-jb9wp9vf3h
    @user-jb9wp9vf3h 6 місяців тому +1

    Enjoyed your video, thank you.💯

  • @deamorta6117
    @deamorta6117 Рік тому +1

    GOLD GOLD GOLD content

  • @Fedjz
    @Fedjz Рік тому +1

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

  • @lautarodapin
    @lautarodapin Рік тому +1

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

  • @realbigsquid
    @realbigsquid Рік тому +1

    100 percent mind blown

  • @Dgiulian
    @Dgiulian Рік тому +1

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

  • @tolgask2812
    @tolgask2812 Рік тому +1

    wonderful content :D

  • @Ste00I
    @Ste00I Рік тому +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.

  • @bartek...
    @bartek... Рік тому +2

    Thanks for your work. Another very valuable video.

  • @petrhavlik
    @petrhavlik Рік тому +1

    Excellent stuff Jack, please keep going!

  • @qodesmith520
    @qodesmith520 Рік тому +1

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

  • @thiagomoraes791
    @thiagomoraes791 Рік тому +2

    great content 😀

  • @vcothur7
    @vcothur7 Рік тому +2

    This is amazing!

  • @kasvith
    @kasvith Рік тому +1

    Great stuff as always

  • @gencomer
    @gencomer Рік тому +1

    Very impressive

  • @luizpaulonascimento9162
    @luizpaulonascimento9162 Рік тому +1

    awesome content

  • @abhishekvishwakarma9045
    @abhishekvishwakarma9045 Рік тому +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
    }
    ```

  • @user-qp4fm7ue6y
    @user-qp4fm7ue6y Рік тому

    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 Рік тому +1

      Good point. Could you provide an example of this?

    • @elmalleable
      @elmalleable 5 місяців тому

      @@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

  • @vasilicampuica6428
    @vasilicampuica6428 Рік тому +1

    Great content, Jack!

  • @erikslorenz
    @erikslorenz Рік тому +1

    I've been loving Jotai thanks Jack

  • @mdjaman7348
    @mdjaman7348 Рік тому +1

    love you bro

  • @MsPrakhar12
    @MsPrakhar12 Рік тому +1

    pretty awesome 🔥 Amazing work

  • @saiyanrivals
    @saiyanrivals Рік тому +1

    Awesome

  • @jeresalem
    @jeresalem Рік тому +1

    Awesome.

  • @vonderklaas
    @vonderklaas Рік тому

    Thanks Jack, captivating as always!

  • @feitan8745
    @feitan8745 Рік тому +2

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

  • @andrepadez
    @andrepadez Рік тому +3

    you're a GOD among men

  • @jamshediqbal7936
    @jamshediqbal7936 Рік тому +1

    Good channel to learn advanced topics 🎉

  • @user-pw4oq9cs3l
    @user-pw4oq9cs3l 7 місяців тому +1

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

  • @rkrupinski
    @rkrupinski Рік тому

    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.

  • @fricze
    @fricze Рік тому +1

    cool stuff

  • @thecodecatalyst
    @thecodecatalyst Рік тому +1

    File tree on the right is the way

  • @shivamjhaa
    @shivamjhaa Рік тому +1

    This is really really cooool!

  • @eliasimokhai
    @eliasimokhai Рік тому +1

    This was tough and fun

  • @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  Рік тому

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

  • @lilpodbebe
    @lilpodbebe Рік тому +1

    Pure gold!

  • @awekeningbro1207
    @awekeningbro1207 5 місяців тому

    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

  • @CrazyWolf132
    @CrazyWolf132 Рік тому +2

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

  • @greatauntmuriel
    @greatauntmuriel Рік тому +1

    explorer on the right is superior

  • @streamoverlayprocodes6890
    @streamoverlayprocodes6890 Рік тому +3

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

  • @download333
    @download333 Рік тому

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

  • @samsurya283
    @samsurya283 Рік тому +1

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

  • @MohamedElmardi123
    @MohamedElmardi123 Рік тому +1

    Amazing!

  • @parassharma7041
    @parassharma7041 Рік тому +2

    A scientist keeps experimenting with react 😃

  • @ToreyLittlefield
    @ToreyLittlefield Рік тому +2

    Challenge accepted 🔥🔥

  • @jasondavis87
    @jasondavis87 Рік тому +1

    I love this!!!

  • @MouseCodes
    @MouseCodes Рік тому +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  Рік тому +1

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

    • @MouseCodes
      @MouseCodes Рік тому

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

    • @MouseCodes
      @MouseCodes Рік тому

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

    • @jherr
      @jherr  Рік тому +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 Рік тому

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

  • @pollettoimpanato
    @pollettoimpanato Рік тому +1

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

  • @bradleyangusmorgan7005
    @bradleyangusmorgan7005 9 місяців тому

    🎯 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

  • @WajuAbolarin
    @WajuAbolarin Рік тому +1

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

  • @GachiTscho
    @GachiTscho Рік тому +1

    This should go to Jotai official docs🤣

  • @rodneydin
    @rodneydin Рік тому +1

    Would it be great if you had a discord server 🎉

    • @jherr
      @jherr  Рік тому +1

      Turns out, I do: discord.gg/sae4SWPAFN

  • @charliematters
    @charliematters Рік тому +1

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

    • @jherr
      @jherr  Рік тому +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 Рік тому

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

  • @frontend_ko
    @frontend_ko Рік тому +1

    Zustand is the next, sir?

  • @Shifter21000
    @Shifter21000 Рік тому

    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  Рік тому

      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.

  • @streamoverlayprocodes6890
    @streamoverlayprocodes6890 Рік тому +1

    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 :)

  • @aliarslanansari
    @aliarslanansari Рік тому

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

  • @michaelscofield2469
    @michaelscofield2469 Рік тому +1

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

  • @adityapanday007
    @adityapanday007 Рік тому +1

    Which extension used for auto suggestions?

    • @jherr
      @jherr  Рік тому

      GitHub Copilot

  • @Maybehassanawad
    @Maybehassanawad Рік тому +1

    Can you please rebuild Valtio🤩

    • @jherr
      @jherr  Рік тому

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

  • @jr-hp7er
    @jr-hp7er Рік тому

    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  Рік тому +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 Рік тому

      @@jherr Thank you so much 🙏

  • @andrewc8125
    @andrewc8125 Рік тому +1

    I think it is time to migrate from Recoil to Jotai

  • @ayushjain7023
    @ayushjain7023 Рік тому

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

  • @thomashermant9321
    @thomashermant9321 Рік тому

    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 Рік тому

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

  • @adamjamiu6764
    @adamjamiu6764 Рік тому

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

    • @jherr
      @jherr  Рік тому

      JETBrains Mono

  • @codingleo
    @codingleo Рік тому +2

    First here woooooohoooo

  • @VKD007
    @VKD007 Рік тому +1

    I thought you will use signals and jotai

    • @jherr
      @jherr  Рік тому +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 Рік тому

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

  • @ak-loz
    @ak-loz Рік тому +1

    :[[
    Eventually I will understand this.

  • @DjLeonSKennedy
    @DjLeonSKennedy Рік тому +1

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

  • @_RobTheRed_
    @_RobTheRed_ Рік тому

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