No BS TS #25 - Typescript/React - useContext

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 พ.ย. 2024

ความคิดเห็น • 42

  • @Rindone75
    @Rindone75 3 ปีที่แล้ว +3

    I just wanted to say that I have been really enjoying these videos! Great refreshers. Could watch the series front to back multiple times over. Thank you and I hope you keep it up!

  • @JimmyGhelani777
    @JimmyGhelani777 ปีที่แล้ว +1

    Thank you for all your hard work putting these together. One of the best instructors i have ever come across - and I have seen a LOT of them!

  • @bachirseghir9952
    @bachirseghir9952 ปีที่แล้ว +3

    React V 18.2.0
    interface TodoProviderProps extends PropsWithChildren {
    initialTodos: Todo[],
    }
    export const TodoProvider: React.FunctionComponent = ({ initialTodos, children }) => (
    {children}
    )

  • @adamlerman4173
    @adamlerman4173 3 ปีที่แล้ว +1

    Was just gonna comment for the algorithm but while I'm at it - just wanted to say that though I'm watching these videos in order to learn ts, I'm actually learning a lot about react as well - thanks Jack!

  • @yannicknana
    @yannicknana 3 ปีที่แล้ว +2

    Yess It answers my question on an ongoing project ! Thank you

  • @sandycochrane7184
    @sandycochrane7184 3 ปีที่แล้ว +2

    When i first started working in typescript a few months back it might as well have been statically typed in wingdings. But now thanks to these tutorials it scans like 18pt Helvetica and by the time ive completed these tutorials im sure Typescript will feel as approachable as some windows 98 wiggly squiggly blue wordart

  • @iuliancarnaru954
    @iuliancarnaru954 3 ปีที่แล้ว +1

    Great content, TS in 2021 is a must have skill.

  • @dianrahmaji
    @dianrahmaji 3 ปีที่แล้ว +3

    love this series 🔥

  • @berkaygurcan141
    @berkaygurcan141 2 ปีที่แล้ว +1

    Perfect really really perfect

  • @theburgermancan
    @theburgermancan 3 ปีที่แล้ว +2

    Great Series fella! Love your work

  • @julianhahn01
    @julianhahn01 3 ปีที่แล้ว +1

    Gotta give you a thumbs up, because you shared you code so well. I struggled with the constrained that i'm only allowed to call the dispatch hook from within a react function. In video you do not show the complete mangaer, but with your repo i was able to find the missnig wrapper function. Thanks!

  • @robx_001
    @robx_001 2 ปีที่แล้ว +1

    No words ... awesome content

  • @victorlongon
    @victorlongon 3 ปีที่แล้ว +1

    I would only add one thing. On those custom hooks i would throw an error if the hook is used outside the correct provider. Kent (Dodds) has a good article about it. Thanks for the video. I am going through the rest of the series i didn't had time to check before 😊

  • @moretimeproductions
    @moretimeproductions 2 ปีที่แล้ว +1

    Took me a while to figure this out, but this video really helps, thank you sooo much!

  • @jakakrajnc5547
    @jakakrajnc5547 2 ปีที่แล้ว

    Hey Jack absolutely love the content!

  • @Stoney_Eagle
    @Stoney_Eagle 2 ปีที่แล้ว

    Since you asked 😄
    So far I got 78.46% of 44702 in my typescript coverage report.
    Typing can be realy difficult and I have some things that I just can't figure out yet, components are fairly simple compared to logic.
    What you mean "Property 'email' does not exist on type 'KeycloakTokenParsed'" I know I do get it from the response so lets create an extendable interface and cast it.
    Knowing this got me a bunch of steps closer.
    I'll just keep chipping away jsx files to tsx till I got 99.9% 😎

  • @ZhenlongYang
    @ZhenlongYang 2 ปีที่แล้ว +1

    great video, thanks Jack!

  • @azzawi
    @azzawi 3 ปีที่แล้ว +4

    Great stuff Jack, I'm not sure why you extracted todos (list), addTodo & removeTodo into their own hooks, they could have been returned from one hook, to reduce extra declarations. imo... yet again, Great work :)

    • @jherr
      @jherr  3 ปีที่แล้ว

      Yep, you're probably right. :)

  • @bscodev
    @bscodev 3 ปีที่แล้ว +2

    Thanks master!

  • @myintegrativecare8359
    @myintegrativecare8359 ปีที่แล้ว +1

    Great content thanks a lot!

  • @miguelyoutube100
    @miguelyoutube100 2 ปีที่แล้ว +1

    Thanks for the video :)

  • @matiasponce2977
    @matiasponce2977 3 ปีที่แล้ว +1

    Loved it !!!

  • @Mannaio7
    @Mannaio7 ปีที่แล้ว +1

    Thanks a lot!

  • @maxklammer3370
    @maxklammer3370 3 ปีที่แล้ว +2

    Cool series :)

  • @surajkmr012
    @surajkmr012 2 ปีที่แล้ว +1

    Amazing

  • @sharqyyem
    @sharqyyem 3 ปีที่แล้ว +1

    Thanks for this awesome content

  • @kettenbach
    @kettenbach 3 ปีที่แล้ว +4

    California could use an overhaul of state management. ☝️😀 Great video JH.

  • @hbela1000
    @hbela1000 2 ปีที่แล้ว +1

    Excellent.

  • @rkingham3181
    @rkingham3181 ปีที่แล้ว +1

    Hey thanks!

  • @stevenwoolston8620
    @stevenwoolston8620 2 ปีที่แล้ว

    Love this content. Question about the duplicated component. Would the right hand side component write data back to the left hand component if you added a todo from that duplicated component?

    • @stevenwoolston8620
      @stevenwoolston8620 2 ปีที่แล้ว

      I watched this video hoping to solve an issue I am having with Authorization context. My app is wrapped in a provider with initial auth data and then i want my user profile form to write to that context when changes are made. So then components which also use profile data are all updated too. Perfect example is changing a user’s avatar. There is an initial avatar, but when they change it in their profile, the avatar displayed in the header changes to reflect the new image. Hoping you can help

  • @codezero6023
    @codezero6023 3 ปีที่แล้ว +1

    Is Redux a standard hook now? Via useReducer?

    • @jherr
      @jherr  3 ปีที่แล้ว

      It's not redux, but it has a very similar API to the reducers portion of Redux.

  • @mattmarkus4868
    @mattmarkus4868 3 ปีที่แล้ว +1

    Hey Jack, if you had two list components that keep their own state of image objects (an array per component) and you need to access the state that each of those components is managing, could you track the state for both in a single context or would you need two? I have a single save button on a form and two image list component instances that aren't sharing state, yet I need to access the state of them on a click handler to make some api requests accordingly. Is there a context solution to this?

    • @jherr
      @jherr  3 ปีที่แล้ว

      I would consider a lightweight state manager (e.g. valtio or zustand) or build a custom hook and share it via useContext. So assuming you want to do the useContext route, start with building a custom hook. Then share the output of that custom hook through context and a provider component. The use useContext to grab the values and callbacks that you need for each component from the context.

    • @mattmarkus4868
      @mattmarkus4868 3 ปีที่แล้ว +1

      ​@@jherr Jack, so are you saying a single hook and a single context and provider?. So both components would be wrapped by the same provider, and each component would reach out to get the data and handlers out of the same context (and update the same context)? Does this mean both arrays that are currently being handled separately in each component would now be one array?

    • @jherr
      @jherr  3 ปีที่แล้ว +1

      @@mattmarkus4868 I'm having a hard time understanding exactly what you are trying to do from what you've said. But yeah, all of the state would be in one hook. And you could pass the image index to the component as a property and it would only "subscribe" to the image at that index. It would help if you joined the Discord server and posted a link to a codesandbox project in there and then we could all have a look at it.

    • @mattmarkus4868
      @mattmarkus4868 3 ปีที่แล้ว

      @@jherr Ok, i posted a sandbox in the channel. I tried to remove as much as possible but I still kept the basic ui concept. At least you can see what type of ui behavior i'm going for. There must be a method to use to end up with a clean api for managing the detail state for any of the tabs. Much appreciated.

  • @kalahari8295
    @kalahari8295 ปีที่แล้ว

    5:30 example of experience worth

  • @ДмитроСорока-г5ж
    @ДмитроСорока-г5ж ปีที่แล้ว

    Thanks!!!!!!

  • @mohsinwaseem9770
    @mohsinwaseem9770 ปีที่แล้ว

    Thank you for all your hard work putting these together. One of the best instructors i have ever come across - and I have seen a LOT of them!