React Context vs Redux - Who wins?

  Рет қаралды 234,137

Academind

Academind

Күн бұрын

Пікірлер: 286
@stannone7272
@stannone7272 5 жыл бұрын
If you know what redux and Context are you can jump strait to 29:08.
@oladiransegunsolomon7750
@oladiransegunsolomon7750 5 жыл бұрын
Thanks.
@MehmetKoseDev
@MehmetKoseDev 5 жыл бұрын
thanks for the 29 minutes you gave me
@codynova
@codynova 5 жыл бұрын
Thanks for that. I feel like his answer is misleading because AFAIK, Redux was built on the old React context API - so presumably using the new context API should be more performant than Redux, but less performant than using state and passing values into nested components. For proof, see blob 8bc14659780c044baac1432845fe1e4ca5123a8d of Redux's connect.js
@Euquila
@Euquila 5 жыл бұрын
rofl
@vzotov
@vzotov 5 жыл бұрын
That should be in the first seconds of this video. I see a lot of people who don't understand and just skip the part where you should use context only for low-frequency changes, and just replace redux with context. Especially after useReducer came out. People think that context is basically new redux, but it is not
@oscarjovanny2403
@oscarjovanny2403 5 жыл бұрын
Thanks to keep me employed Max! You've done more for me than my University ❤️
@academind
@academind 5 жыл бұрын
Haha, that's amazing to hear! I'm glad you're liking the content!
@thiagovilla970
@thiagovilla970 4 жыл бұрын
I second that
@luisbalza3774
@luisbalza3774 2 жыл бұрын
I third(?) that
@kushalbansal5508
@kushalbansal5508 4 жыл бұрын
1) react with class components and context api 2) react with functional components(hooks) and context api 3) react with class components and redux -> These are the three options which he explains through three different videos -> Depends up to you and your project requirements Thank you for these videos really means a lot
@justsomeguy8385
@justsomeguy8385 5 жыл бұрын
Good video. I'm disappointed that you didn't show how much simpler the context API is when you use functional components and the useContext hook. To me, that might actually be its biggest advantage at this point.
@academind
@academind 5 жыл бұрын
That is coming! I already created a video on that :-)
@misterkevin_rs4401
@misterkevin_rs4401 5 жыл бұрын
@@academind Already waiting for that video! You make great content, as always
@devcaand
@devcaand 2 жыл бұрын
What if you need to hydrate your store? It has pros and cons, don't say one better than the other without knowing underlying issues and headaches. There is a lot more to that than just context api is less code let me pick that one...
@natture
@natture 2 жыл бұрын
@@academind do we have video on that
@cancer10in
@cancer10in 4 жыл бұрын
Summary: If your application has high-frequency updates (like updating dashboard with data pulled from the server) then use redux, if your app has low-frequency updates (like changing user avatar, password, or login) then use context API.
@BrandonClapp
@BrandonClapp 5 жыл бұрын
Interesting, thanks for such a detailed comparison. While it may be more boilerplate, I feel like redux provides additional organizational and decoupling benefits. I feel that Contexts tightly couple your child components to their component hierarchy, reducing their reusability in another app (which is arguably the entire reason for a "component" based model). Secondly, I don't like how business logic is moved into the presentation layer. I can definitely see how Contexts could be used for common properties needed by many components like locale, theme, etc. I do realize that all projects don't have to be architecturally "the best", so long as they serve the purpose. I can see how Contexts could work in smaller applications where component reusability isn't a big concern. Once again, thanks for the explanation!
@limyohwan
@limyohwan 2 жыл бұрын
yea i don't get why this comparison is made using a simple example. The whole point of Redux is managing complex applications. This video is like doing a test of IBM mainframe by showing us how to use it to play minecraft. That's just not what it's for.
@nardbagel
@nardbagel 5 жыл бұрын
hmmm. I personally would just create the provider where you create the context, with all of its methods that edit state inside the component, and then from that file export provider and consumer. That would let you avoid the global state problem you are creating. Also, I would put the functions into the state instead of creating a new object every time inside of the providers value, that will cause the component to re-render too often.
@siddhantjain2402
@siddhantjain2402 5 жыл бұрын
Wow! You won't believe I was just thinking about searching for Redux Vs Context when the notification popped out. Thank you so much! ❤️
@academind
@academind 5 жыл бұрын
Awesome to read that the timing was right for you Siddhant, thank you for your comment!
@terasoft-official
@terasoft-official 4 жыл бұрын
Google knows everything. that happens to us
@dnielsen9713
@dnielsen9713 5 жыл бұрын
"its not so much about the UI but the functionality" -Every coder in existence
@serdarsimsek3686
@serdarsimsek3686 4 жыл бұрын
Answer is simple use contexts. Redux is unnecessarily complex for such simple actions and whenever you dispatch an action it notifies all the reducers so this is causing too many side effects when the project is becoming complex. And after a while you are becoming choking between the actions. But contexts are super suitable to solve the problems in their own contexts i.e when you need to connect between menu items you can create menu context and solve everything around it. And if you need more interactions create context to combine contexts and solve all interactions on place. This is basically much suitable divide and concur principle.
@rajjyotidoley5087
@rajjyotidoley5087 2 жыл бұрын
you just made context sound more complex.
@serdarsimsek3686
@serdarsimsek3686 2 жыл бұрын
@@rajjyotidoley5087 Haha depends on your intelligence 😀
@sushispicelatte
@sushispicelatte 5 жыл бұрын
Developers have a hard time making up their mind.
@ebinxavier8589
@ebinxavier8589 5 жыл бұрын
Thank you brother. I was about to use Context API in my next project, but will stick with redux as you mentioned.
@Denzelzeldi
@Denzelzeldi 5 жыл бұрын
28:40 - TLDR - Summary on React Context vs Redux.
@ATageH
@ATageH 5 жыл бұрын
Context API for me, it can be used for about 90% of the cases that people tend to use Redux for and Redux is honestly a mess and you have to jump through so many hoops to get thing working. It doesn't strikes me as very future proof (React Native Navigation isn't going to be supporting it soon). With Context API and Hooks along with the rest React provides out of the box Redux kind of feels Redundant.
@aArcziMetin2
@aArcziMetin2 5 жыл бұрын
Redux is a mess? Really?
@vaheghevondyan9437
@vaheghevondyan9437 5 жыл бұрын
You can use React Navigation and it works very well with redux. I think redux is more flexible than Context API
@Gigusx
@Gigusx 5 жыл бұрын
I also like Redux more.
@pigvodoi
@pigvodoi 5 жыл бұрын
really? have you worked on any big projects?
@ATageH
@ATageH 5 жыл бұрын
@@pigvodoi Rather use MobX for those
@QuangNguyen-zl1mq
@QuangNguyen-zl1mq 5 жыл бұрын
Finally who win ? Redux or Context ? please tell me.
@mucahittezcan4121
@mucahittezcan4121 5 жыл бұрын
Just use what ever you want... but contextAPI is easier right now with hooks. (useContext)
@DEVDerr
@DEVDerr 4 жыл бұрын
@@mucahittezcan4121 Not anymore. Redux simplified his bullshit boilerplate offering their own hooks and removing mapStateToProps or connect() function
@DEVDerr
@DEVDerr 4 жыл бұрын
For me obviously Redux since it provides great tooling with timeline feature which I think is necessary for larger companies, but I understand people using Context in much simpler and smaller projects
@DavidSmith-ef4eh
@DavidSmith-ef4eh 5 жыл бұрын
Well, was watching this for the last 5 min, where he basically tells that you should use REDUX for high frequency updates and Context API for low frequency.
@JohnSmith-bb1sv
@JohnSmith-bb1sv 4 жыл бұрын
His advice is an appeal to authority. It's also almost 2 years old now. I will go out on a limb and say you aren't going to need Redux 95% of the time.
@DavidSmith-ef4eh
@DavidSmith-ef4eh 4 жыл бұрын
@@JohnSmith-bb1sv Well, after doing several projects on my own, I'd just suggest everyone to use MobX for everything. It is really that good, even for simple projects.
@JohnSmith-bb1sv
@JohnSmith-bb1sv 4 жыл бұрын
@@DavidSmith-ef4eh Awesome David, thanks. I will check that out. I started learning Redux because that's what job postings were asking for. It seems to me that there are many "best practices" which could lead to over-engineered apps. It makes more sense to start with useState, then very simple prop drilling, then move to useContext, then finally Redux - as the project grows in complexity. Personally I think that 90% of the work that gets done should be able to be completed by someone with 8 to 16 hours of experience in the platform - whatever it is. For example, functional React components are so simple anyone with basic Javascript ES6 skills can do them. Using Redux on a web page with a few components is overkill. Maybe for something like one of those online text editors like CodePen.
@DavidSmith-ef4eh
@DavidSmith-ef4eh 4 жыл бұрын
@@JohnSmith-bb1sv Well redux has it's advantages (being able to travel through history, saving application state to json..). But the cool thing in all of that, MobX can support similar functionalities with MobX-State-Tree package. I wouldn't discourage anyone from learning redux. Nothing wrong with learning different approaches.
@heyl_yt
@heyl_yt 5 жыл бұрын
I see one major problem with React Context. Its performance. By default all components connected to Context are rerendered, thus optimalization isn't as easy as in Redux. Redux splitting business logic by default is also a nice thing.
@incarnateTheGreat
@incarnateTheGreat 5 жыл бұрын
@Academind What do you think about this? In your example, you wrapped your Provider around the BrowserRouter. Is that the only way to go? Will you constantly re-render components because of Context updates?
@lucas.n
@lucas.n 4 жыл бұрын
this Context idea reminds me a lot of the Emberjs mantra "data down, actions up". It's nice how they abstract a whole lot of boilerplate from the dev.
@notthere83
@notthere83 5 жыл бұрын
All of these discussions IMO are too focused on API and performance. When one of the major benefits of redux is keeping an overview of operations that can manipulate the state as well as being able to debug state changes easily through its devtools. I find that handy even for small apps and for large apps an essential piece to improve maintainability.
@marvequelistino1274
@marvequelistino1274 4 жыл бұрын
I am actually a novice and I have just completed the ReactJS and ReactJS-Redux basics of Academind just today (seriously). In my opinion, I agree with your view. Being a developer in my career who focuses more on debugging, I would prefer to use all the tools that will help me debug my code properly. Code readability is always a second priority in my opinion. This comment needs to be up there.
@ibrahimalshekh831
@ibrahimalshekh831 4 жыл бұрын
Are you mean that Context API is created to be a replacement of Redux but it is not ready yet to be used in all cases I think we should avoid the third party packages as long as possible.
@dimaster5880
@dimaster5880 5 жыл бұрын
I think I fell in love with Context.
@danko95bgd
@danko95bgd 5 жыл бұрын
I wish they implement one of the react rfcs' in the proposals for like setting the values to global context or something, its gonna be great if they do it, would be an official api and then we could have libraries add more on top of that.
@shilangyu
@shilangyu 5 жыл бұрын
I don't like how using context.provider on the App component re-renders the whole app every time the context was changed. "use multiple contexts" is what I usually hear, however I find using multiple contexts very cumbersome. What are your thoughts?
@efreitorhabibulin238
@efreitorhabibulin238 5 жыл бұрын
same thing with redux... context api is not meant to be used like in this simplified example, you shouldn't wrap entire router with your providers unless it is something global like "AppContext" or "I18nContext" which needs to re-render entire app, i hope you understand what i mean without over explaining.
@Dorumin
@Dorumin 5 жыл бұрын
@@efreitorhabibulin238 I prefer to go the masochist route and instead re-render every component that needs the i18n ;)
@dand4485
@dand4485 4 жыл бұрын
Might be a noob question, i'm wondering if it might be convenient when building up the state object in the Provider, why not have useState for the products added in from what would be the destructured object say [product,setProducts] we get from the useState(productCollection). Any down side to this? As mentioned still learning React and not sue when i tried doing this (easy i didn't have something setup correctly) but was getting errors something to the effect "Can user hook methods within other hook methods". If it makes sense and fine then i'll try working through my fat fingered errors... Thanks in advance :)
@rtorcato
@rtorcato 5 жыл бұрын
Redux is built on React Context so think of Redux as context on steroids with nice redux dev tools. If you have a simple app use context, but if you expect your app to grow use Redux.
@justsomeguy8385
@justsomeguy8385 5 жыл бұрын
There is no reason your app can't grow with just context. If you're worried about wrapper hell, then use hooks.
@incarnateTheGreat
@incarnateTheGreat 5 жыл бұрын
@@justsomeguy8385 Agreed. React decided to implement Context because it would make it easier to access high-level content, but more importantly, they added it to make using React easier. I don't think they would have implemented Context if they didn't think it could handle scaleable applications.
@romanchuk_vlog
@romanchuk_vlog 5 жыл бұрын
The reason App grows is redux
@rakeshpk4991
@rakeshpk4991 4 жыл бұрын
Great tutorial. I wached a number of tutorials on this subject and this is the best. I recommend everyone should follow this channel if you want some serious information!
@AlterMuller
@AlterMuller 5 жыл бұрын
I don't get why it's Colt Steele that gets the cult following. I mean, I like the man and his content but this is on a whole another level. I've just finished Max's React course and still keep coming back for more!
@academind
@academind 5 жыл бұрын
I think Colt also has great courses, but I'm very happy with the support I get and with awesome feedback like yours, thanks a lot for that!
@valentynrubliuk4290
@valentynrubliuk4290 5 жыл бұрын
Hi Max, please make a video about Hooks in React 16.8.
@academind
@academind 5 жыл бұрын
This might be interesting for you => academind.com/learn/react/react-hooks-introduction/
@valentynrubliuk4290
@valentynrubliuk4290 5 жыл бұрын
​@@academind Yes, it is. Thanks!
@Gigusx
@Gigusx 5 жыл бұрын
@@valentynrubliuk4290 damn... ask and you shall receive?
@valentynrubliuk4290
@valentynrubliuk4290 5 жыл бұрын
@@Gigusx Yeap :)
@NotTheLastOne
@NotTheLastOne 5 жыл бұрын
@@valentynrubliuk4290 he has got it in video lessons as a part of his react guide on udemy
@gwapster13
@gwapster13 5 жыл бұрын
Hmmmm.... but React-Redux is based on Context anyway, isn't it? For really high frequency updates like storing keystrokes (your example at the end), I would use local/component state, not even Redux. Context and Redux are simply not mutually exclusive... in fact React-Redux is based on Context API. But I know this comparison is rather "React-Redux vs. Context", and in that regard, React-Redux simply adds the Redux benefits to the otherwise plain Context API. So your conclusion that Context API should not be used for high frequency state changes, wouldn't that also apply to React-Redux? I think I remember even Dan Abramov mentioning before that there are cases like that when local state is all that's needed instead of Redux. Am I missing something here? Great video as usual BTW, and same goes to your online courses which I used a bunch of.
@MrAlouini333
@MrAlouini333 5 жыл бұрын
I personally like the video and I find it more helpful to understand Redux. Bravo 👏👏👏 Can you make a comparaison between Redux and Mobx please?
@petarkolev6928
@petarkolev6928 3 жыл бұрын
Thank you for the video, Max! As always - awesome
@The-Dirty-Straw
@The-Dirty-Straw 5 жыл бұрын
I strive to be a super nerd like you guys. Luckily I'm getting a good grasp at Context and know what's coming with Redux now.
@angusmcintyre8025
@angusmcintyre8025 5 жыл бұрын
Is bundle size really your primary motivation here? Redux + asynchronous action is a) common and b) reliant on enhancers and middleware. Shouldn't standardisation and simplification be driving force?
@Ant0n009
@Ant0n009 4 жыл бұрын
Regarding the last few minutes of the video on context/high frequency updates - I thought Redux also uses context behind the scenes. So wouldn't Redux face same issue? Unless Redux has some solution for this?
@johanburmester9608
@johanburmester9608 5 жыл бұрын
Hi, why should you use context instead of just passing down your state and update function as props? The prop could point to a update function in App which update its state. Great video! I will try Context next, it seams much easier!
@tarkeshduttpant4938
@tarkeshduttpant4938 5 жыл бұрын
Because then you would have to pass props to children and then further children of the children , context give access to state from anywhere )
@SergioArroyoSailing
@SergioArroyoSailing 4 жыл бұрын
in the past year, has the Context API been revised so that the final argument for not using Context everywhere has been nullified?
@tonkihonks3430
@tonkihonks3430 5 жыл бұрын
Can someone explain why you need the same *data* in both context/shop-context.js and the app.js with the exact same data? Why do we need in both places?
@wkolcz
@wkolcz 4 жыл бұрын
I was about to ask the same question...just a year later
@smsibasish
@smsibasish 4 жыл бұрын
What's the point of using both Redux and Context in the same app?
@aurelianspodarec2629
@aurelianspodarec2629 5 жыл бұрын
Still the same outlook on it? Since 6months have passed
@subhadippahari1244
@subhadippahari1244 5 жыл бұрын
I got into a confusion over react context api. If you can help , it will be really helpful. Question : is it OK to use multiple independent context in react app. Means those contexts will not be communicate between them , but they will exists in parallel . Each context will handle multiple react routes ... Route a1 Route a2 Route a3 Route b1 Route b2 Route b3
@thedeveloper4207
@thedeveloper4207 5 жыл бұрын
Fuck off....this is youtube
@peterhudecdotcom
@peterhudecdotcom 5 жыл бұрын
It's a shame that you didn't compare those two in terms of composability, scalability and maintainability, which is where they actually differ. Also, there is absolutely no problem with frequent updates to the context whatsoever. This example, which is even simpler than the traditional todo list is completely detached from reality. Arguably global variables are even simpler and less of a boilerplate and would make for an even simpler example. Are global variables the next big thing replacing both Redux and Context API? Well, you may give it a try and figure out for your selves. The problem with all these comparisons is that they measure the complexity by the boilerplate, which is an unlucky choice of metric. Redux is actually extremely simple which I think is its most valuable feature. It provides a set of simple rules and composition guidelines. If you just stick to those rules, Redux will take you safely very far. It is proven that you can build huge, complex and performant real-time applications with it (despite the fact that the data is delivered to the components by way of context in react-redux), and all that using only pure functions which are the simplest building block you can think of and which are extremely easy to test. You only need impure functions for side effects which are all pushed to the boundary of your app i.e. the middleware. Nothing beats Redux's simplicity, except maybe The ELM Architecture. But certainly not imperative updates to local state of context providers scattered all over the place interfering with each other.
@robertshawnmitchell
@robertshawnmitchell 5 жыл бұрын
Would be good to see this same sample implemented with hooks, useContext, even useReducer
@academind
@academind 5 жыл бұрын
Coming soon!
@mydisk2859
@mydisk2859 3 жыл бұрын
I think there should have been comparison for bundle size as well for both usecases...
@foobargeegasp
@foobargeegasp 4 жыл бұрын
Thanks for this great video Max. On the reasons to still consider redux you mention "high frequency updates". There is, IMO, another reason that is related to the additioal libraries that work with redux, such as redux-persist. With redux-persist it is straightforward to persist your reducers in the local storage, which is a popular requirement. It is possible by using the Context API?
@Pewpewz
@Pewpewz 5 жыл бұрын
I prefer Context over Redux for pretty much all global state communication. I haven't found a use-case yet where i would use Redux over it. I think people who don't understand Context, or haven't used it and are used to Redux, are the only ones who play down Context.
@ΣτάθηςΣταθόπουλος-σ7ρ
@ΣτάθηςΣταθόπουλος-σ7ρ 2 жыл бұрын
Never used anything. Tried both. 100% prefer Redux. Decoupling, cleaner/orginized code. Also the key here is Performance. I tried some unit tests with 3 different projects. Redux won by a lot on all 3 of them without any extra optimizations.
@Pewpewz
@Pewpewz 2 жыл бұрын
@@ΣτάθηςΣταθόπουλος-σ7ρ Redux isn't clenaer code, and it's not decoupled any more than Context. Context is a hook, one line of code. "Redux won by a lot" sounds like BS to me.
@fuu812
@fuu812 5 жыл бұрын
mate, the quality of these videos are absolutely fantastic, thanks!!
@academind
@academind 5 жыл бұрын
Awesome to read that, thanks a lot for your great feedback!
@HabibAlSaki
@HabibAlSaki 5 жыл бұрын
hey Max, thanks for your effort for our learning. I have a request. Can you please make a video on how to design a solution for a project before start coding? It may be on OOP or anything you wish.
@aammssaamm
@aammssaamm 4 жыл бұрын
These guys hardly know the answer otherwise they would never write such a mess.
@nicksergeev1641
@nicksergeev1641 4 жыл бұрын
Will you record the NgRx tutorial just like for the Redux?
@kadekeqw23
@kadekeqw23 5 жыл бұрын
Great video. Is the difference between using "AppContext.Consumer" and "static contextType" is just syntax? If so, I might switch over to using "static contextType" because using the "AppContext.Consumer" wrapper is quite visually confusing to me.
@yevhenkozlov286
@yevhenkozlov286 5 жыл бұрын
just to highlight: we cannot list multiple contexts in "static contextType" but can do it utilizing "AppContext.Consumer" form
@mingyan9538
@mingyan9538 5 жыл бұрын
Very nice video explaining the purposes and use cases for these two different tools! Thanks
@hh83917
@hh83917 5 жыл бұрын
You can use useContext + useReducer hooks to imitate redux. However, what I understand is, context may cause all the child components using it rerender everytime as it doesn't do any diffing on it's own. Redux use context under the hood as well, but it does a lot more optimization and shallow diffing to prevent everything from rerendering when not needed. So redux is not going away yet.
@jjjjjjjjwwjwjw
@jjjjjjjjwwjwjw 5 жыл бұрын
hh83917 this is what I was wondering about as well. Doesn't this have a huge negative of all children rerendering? Would love some clarification here since that makes it not a viable replacement. If I have to utilize shouldComponentUpdate in the children manually, that would also not be feasible n
@hh83917
@hh83917 5 жыл бұрын
Ji Park from what I’ve read, the easiest way is to put the stuff you want to pass to context provider in the component this.state, even the handler functions, and let react do the diffing for you.
@lahcenechel1855
@lahcenechel1855 3 жыл бұрын
Which one should I use now 2022 mobx recoil or redux?
@yfzhangphonn
@yfzhangphonn 5 жыл бұрын
When you start testing, you will regret had react context on board
@iscratchmybutt
@iscratchmybutt 5 жыл бұрын
lol good point
@tonydanza4502
@tonydanza4502 5 жыл бұрын
Why?
@coherentpanda7115
@coherentpanda7115 5 жыл бұрын
@@tonydanza4502 Redux has bundled tools you can use for testing. The timeline feature is valuable, especially in large projects.
@persoulrpg
@persoulrpg 5 жыл бұрын
How come? When used correctly, I have no issues writing tests for the context API
@persegona77
@persegona77 5 жыл бұрын
Hi Max. I noticed that you have increased your React content on KZbin and I was wondering if you are starting to like it more than Vue?
@academind
@academind 5 жыл бұрын
No, I still like all 3 frameworks/libraries. We just didn't have a lot of React content in the last months, that's why I wanted to release some videos on it, especially with big changes like the recent introduction of Hooks.
@parrot785
@parrot785 4 жыл бұрын
Thanks for this video! Just what I was looking for!
@peepeepoo3432
@peepeepoo3432 5 жыл бұрын
React-redux uses the context api for its Provider to work, how can that be faster than using the Context API alone?
@nikilk
@nikilk 5 жыл бұрын
David K Marshall I guess the only way to really tell is measuring performance with high frequency updates with redux / context api.
@rui_mcf
@rui_mcf 5 жыл бұрын
I was wondering exactly this as well
@peepeepoo3432
@peepeepoo3432 5 жыл бұрын
@@rui_mcf If you're interested I dug a bit and it seems like React-redux provides a lot of internal performance optimization and avoids common pitfalls that can happen when using Context. If you use Context without knowing exactly what you're doing you may end up re-rendering your entire tree at times. So yeah, that's the reason.
@VinitDave
@VinitDave 5 жыл бұрын
Hi Max, do you have any videos for typescript with react and webpack?
@ourmodernlife1524
@ourmodernlife1524 4 жыл бұрын
hi thank you for this video, I am still wondering why do we need to import (the context) in the consumer component, why it's not enough to use the value we passed from the provider to the consumer?
@monkeyhammer137
@monkeyhammer137 5 жыл бұрын
Hi Max are you planing to update your React Native course in the near future ? The one from previous year is well outdated.
@academind
@academind 5 жыл бұрын
The course is not outdated, I constantly test the course and it is working fine with the current version, therefore I do not plan to update it in the near future.
@m4ynor
@m4ynor 4 жыл бұрын
I cannot get the idea behind putting navbar in every component. Needed check the GitHub code to understand it clearly
@m4ynor
@m4ynor 4 жыл бұрын
I still don't like it
@seanc846
@seanc846 4 жыл бұрын
Paused at around 11 minutes here...racking my brain as to why duplicate the App state information with the context information?!?!?! What's the point then? Is there a way for App to pull in the context data without having to copy and paste like that?
@ivanivanov144
@ivanivanov144 5 жыл бұрын
Do i understand right what chenges in context not triggering rerender? We changing context in mutations manner? It behave as class with static fields and methods. (im using TS)
@muzafferckay2609
@muzafferckay2609 3 жыл бұрын
Could you please make a tutorial how can we implement multiple context ?
@andresmontoya7852
@andresmontoya7852 5 жыл бұрын
Awesome! But what about Mobx?
@dean6046
@dean6046 5 жыл бұрын
Thank you for this Max!
@Sean-uo9kw
@Sean-uo9kw 4 жыл бұрын
The universe must not want me to watch this video because I have restarted my browser already once to watch this and I'm going to have to do it again. Edit: tried 4 different times youtube is bugging right now.
@tambolaking5383
@tambolaking5383 4 жыл бұрын
Can context replace saga too?
@ChrisMcFlyDude
@ChrisMcFlyDude 5 жыл бұрын
Thank you for providing clarity. Much appreciated.
@ruznyahamed874
@ruznyahamed874 5 жыл бұрын
Thanks! I was really looking forward to having this from you Of Course!
@dhano6sk
@dhano6sk 5 жыл бұрын
This may be a silly question but when we pass this in bind, how come that addProductToCart is executed on correct object - GlobalState and not on this that is passed in bind. I assume that this in bind points to Product object?
@guilhermedosreis2459
@guilhermedosreis2459 5 жыл бұрын
I am not sure, but i think, that in this case, this is a reference for the context object.
@r0x304
@r0x304 4 жыл бұрын
“Awaiable”, how adorable.
@markuspfeifer8473
@markuspfeifer8473 4 жыл бұрын
So... essentially the context api essentially currys a continuation??
@vigneshpts478
@vigneshpts478 4 жыл бұрын
Can you please post videos about redux-ORM as we couldn't find videos any. If you post regarding that it could be useful.
@tonydanza4502
@tonydanza4502 5 жыл бұрын
I like the way he says “of course”
@kasper369
@kasper369 4 жыл бұрын
can u please update this video, how to do with functions instead of class
@karlomoonblade
@karlomoonblade 5 жыл бұрын
i have no time to finish the vid , so who wins?
@ob34915
@ob34915 5 жыл бұрын
redux hands down for big projects
@dreamyrhodes
@dreamyrhodes 4 жыл бұрын
no
@davidacosta6383
@davidacosta6383 5 жыл бұрын
Very well done, well explained, didn't miss a beat! THANK YOU!!!
@persoulrpg
@persoulrpg 5 жыл бұрын
So the summary is "use context api for low frequency updates". Well, first of all, it depends on how you use the provider. Imho, you shouldn't be using Redux for high frequency updates either and keep it on component state whenever possible to reduce re-renders. Right? Or Redux does some magic on that? Internally, Redux makes use of the context API anyways. Also, be aware of the fact that React team will improve context API more and more to deliver baked in solutions for new devs because the non-sense has to stop: in order to use react in real world applications you had to use some external libraries and learn the ecosystem which wasn't cool.
@academind
@academind 5 жыл бұрын
React-Redux does not use context for pushing state changes to components. It uses a subscription system instead. That's an important difference. Only components that do require a change will get it (and be re-rendered). Whereas with context, changes always go through the entire component tree in the end.
@persoulrpg
@persoulrpg 5 жыл бұрын
@@academind Oh, that makes sense, good point. Although I think it's possible with context and hooks to create some subscription based state too, no?
@peterhudecdotcom
@peterhudecdotcom 5 жыл бұрын
There's no problem with high-frequency updates neither in Redux nor Context API, the bottleneck is always React itself.
@MrRahul777777
@MrRahul777777 5 жыл бұрын
Thanks a lot for this course. Please can you suggest me a course for SQL with React-Redux and Node JS. I would be thankful to you. :)
@gomriria2197
@gomriria2197 3 жыл бұрын
Hello, i really dont like the contexte api if Somme composent need to cummunicate i do a state lifting in the first common parent. Also redux have the push subscribe pattern (push the action subscribe to state changes) I find it more intuitive
@konstantinze
@konstantinze 5 жыл бұрын
Hi Max what if I wanna use the context outside as a global state like axios interceptor how can i do that?
@termitavee5726
@termitavee5726 5 жыл бұрын
I created a context.js file where I stored the context. Then, I create the Component that provided the context and created functions that modify it and store those functions on the context.js file so you can edit it globally (you can do this also with state variables but I would't recommend it but depends on what kinsd of information)
@vzsshadow3141
@vzsshadow3141 5 жыл бұрын
what about mix contextapi with redux? example we store products in redux but user login or theme in contextapi, so it is smart to use both in same project?
@oladiransegunsolomon7750
@oladiransegunsolomon7750 5 жыл бұрын
That will make your code verbose and overly complex using two global states is not adviced
@DaggieBlanqx
@DaggieBlanqx 4 жыл бұрын
Great explanation sir... you've introduced me to Context API
@khmaieshassen
@khmaieshassen 5 жыл бұрын
you lost me in the final part :/ should i use it for ecommerce website like in your example or in an elearning website or should i keep using redux for that ?!
@josephjoey3904
@josephjoey3904 5 жыл бұрын
I was thinking to build a forum using context api sans hooks but now I'm also confused
@nostacktofullstack
@nostacktofullstack 4 жыл бұрын
Thanks for this video, so many doubts are clear now.
@sumitwadhwa8823
@sumitwadhwa8823 3 жыл бұрын
Redux is being used as a cache library for remote state is kinda screwed up. Local state (like locale, theme, etc) can be managed by the context api and remote state (async state) can be managed by libraries like react-query. Redux is an overkill for most applications.
@superknife0512
@superknife0512 5 жыл бұрын
Hi Max, can you make a series guide how to make a chat app with socketio, nodejs, react/vue as frontend, I mean a chat app can send private message to each other, or can create a group chat like facebook messenger, I 've read socketio documentation but it 's a bit vague, and lack of showcases. Thank you. I'm also your student on Udemy.
@임창수-c7c
@임창수-c7c 5 жыл бұрын
Thank you Max. I want your videos about mobx!
@academind
@academind 5 жыл бұрын
Thank you for your comment, no plans to create videos on MobX in the near future though, sorry.
@임창수-c7c
@임창수-c7c 5 жыл бұрын
​@@academind It's okay!
@skyzhangty1
@skyzhangty1 5 жыл бұрын
Isn't react-redux using context under the hood as well?
@srikkanthank
@srikkanthank 5 жыл бұрын
How to get these colorful icons in VS Code?
@academind
@academind 5 жыл бұрын
Just install the Material Icons Theme => academind.com/learn/web-dev/visual-studio-code-introduction/#our-visual-studio-code-setup
@makisetakashi
@makisetakashi 5 жыл бұрын
Great example , easily to understand flow of context API
@AstrusHD
@AstrusHD 5 жыл бұрын
Nices Video wie immer! PS: Man hört, dass du deutsch bist 😀
@Loppy2345
@Loppy2345 5 жыл бұрын
Context for simple apps, Redux for complex apps and to scale.
@mspandey1616
@mspandey1616 4 жыл бұрын
@academind : how to create project structure for an application as big as Facebook. Like how to design redux, store, react-hook-forms, etc for such a heavy application.
@mspandey1616
@mspandey1616 4 жыл бұрын
@Academind Creating small project is ok. But how to do it for larger projects like a pro.
@ssengalanto7421
@ssengalanto7421 5 жыл бұрын
Hey max are you the one in the wix ads?
@academind
@academind 5 жыл бұрын
No, I'm not part of these ads ;)
@ssengalanto7421
@ssengalanto7421 5 жыл бұрын
@@academind I see you just look like him, anyway I've been following your channel lately, and you're one of the best out there, thank you for your great videos and tutorials It helps me a lot, I'm gonna take your node.js tutorial once I'm ready to dive into it :D
@manishankar1779
@manishankar1779 3 жыл бұрын
Can anyone tell me what are the changes I have to make in index.js if I am converting the app from redux to context api. Also can I completely remove action and reducer file ?
@octr9k
@octr9k 5 жыл бұрын
thx for the video, what about useContext + useReducer ? may this combination replace Redux
@DavidSmith-ef4eh
@DavidSmith-ef4eh 5 жыл бұрын
I think it works great if your state is not an object, since react will re-render every component that uses the context, when context changes. So each time you change the object, it will re-render even the components that use a property of the object (state) that didn't even change. Maybe there are some solutions for this re-rendering problem besides using redux... Maybe future versions of react will handle this better..
@octr9k
@octr9k 5 жыл бұрын
@@DavidSmith-ef4eh thought re-render problem can be handled with useEffect() method
@DavidSmith-ef4eh
@DavidSmith-ef4eh 5 жыл бұрын
@@octr9k we'll see, I'll let other people think about it and once they come up with a solution I might adapt it...
@thiagovilla970
@thiagovilla970 4 жыл бұрын
Does anyone know what plugin for those gorgeous icons on the tree view???
@Malcolm777-i
@Malcolm777-i 4 жыл бұрын
Try material icons
@hehe_ylime
@hehe_ylime 5 жыл бұрын
what is point of setting default value when you instantiate context if we have to set default value on context component with using value?
@jjjjjjjjwwjwjw
@jjjjjjjjwwjwjw 5 жыл бұрын
It is just a set up to use the Context mechanism. He mentions that you don't need to provide a value, but it's easier since it'll provide you with auto complete info if you do n
@hehe_ylime
@hehe_ylime 5 жыл бұрын
​@@jjjjjjjjwwjwjw thank you. I missed 7:00 part
Mastering React Context: Do you NEED a state manager?
37:26
Jack Herrington
Рет қаралды 100 М.
useContext() + useReducer() = Magic?
22:49
Academind
Рет қаралды 183 М.
Trick-or-Treating in a Rush. Part 2
00:37
Daniel LaBelle
Рет қаралды 45 МЛН
КОГДА К БАТЕ ПРИШЕЛ ДРУГ😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 8 МЛН
風船をキャッチしろ!🎈 Balloon catch Challenges
00:57
はじめしゃちょー(hajime)
Рет қаралды 76 МЛН
Context против Redux | Разбираемся что лучше
21:07
State Managers Are Making Your Code Worse In React
13:33
Web Dev Simplified
Рет қаралды 199 М.
React.js Hooks Crash Course
1:02:54
Academind
Рет қаралды 317 М.
Don't Use React Context!! Use This instead
13:34
CoderOne
Рет қаралды 29 М.
How Mario Kart 8’s Checkpoints Were Finally Broken
19:53
React Context API with TypeScript | UserContext React TypeScript
14:47
WebDevWithArtisan
Рет қаралды 15 М.
ПОЛНОЦЕННЫЙ ГАЙД ПО REACT CONTEXT
35:45
Ayub Begimkulov
Рет қаралды 10 М.
Goodbye, useEffect - David Khourshid
29:59
BeJS
Рет қаралды 503 М.
Trick-or-Treating in a Rush. Part 2
00:37
Daniel LaBelle
Рет қаралды 45 МЛН