Let’s see.
While checking out the blog about the new version of React...
I found something that I really liked.
It’s nothing amazing.
Nothing that’s going to change our future for the better.
Nothing unheard of.
Anyway.
It’s simple.
But effective.
Just as it should be.
It’s nothing more and nothing less than...
( … Drumroll … )
…
<Context> as a provider
Yes! What does this mean?
It just means that now, when you use the classic old <Context.Provider>
in React,
you don’t need to add .Provider
anymore.
That is,
Before:
const ThemeContext = createContext('');
...
<ThemeContext.Provider value="light">
{children}
</ThemeContext.Provider>
Now:
const ThemeContext = createContext('');
...
<ThemeContext value="light">
{children}
</ThemeContext>
Honestly, what a joy.
I never really understood why it wasn’t like this.
From the start.
It was pretty annoying having to always add the .Provider
.
Not too much.
But a little, you know what I mean.
Also, they’ve published a codemod to convert the existing providers.
Perfect.
These days, the course will be updated with this change.
What course?
This one right here:
Ps: Above. You'll never be able to buy it at a cheaper price. In less than 2 hours, you'll know more about setting up React TypeScript projects than 99.9% of the devs out there.