React context help

Hi campers , how are you all ? ,I hope you are so good .
Please I have two questions.
The first : is about React context API ,I understand the concept and why we use it ,but in React docs in this part :

I could not understand to where this.context reffers.
Here is the page
My second question : when I learn something I want to know how it is created for example reduce function in JS ,one day I wanted to know how they created it ,I still think this is a good habit to be more skilled in code , am I wrong ?

1 Like

Hello :slight_smile:

In the Context API this.context is the value of your provider. For example:

<MyContext.Provider value={/* you can access this value using this.context */}>

About the second question, I think you are right, knowing how things work under the hood is really good, in the end of the day it helps you to understand better how the language works. Just keep in mind that this is good for learning but in a job you probably will use some framework or anything that make you more productive and your code cleaner, more readable and maintainable.

1 Like

No better way of learning how something works than by implementing it yourself. If you know what reduce() does, try implementing it yourself. It’s actually about as easy as implementing map().

If you work a lot with React, you’re going to run into Redux (which imho is a lot nicer than working with the context API) at which point you’ll definitely be getting familiar with the reduce() function.

1 Like