Context API - Behaviors
Hooks and Context example
With regard to the React Context API, what does a “provider” do? A provider allows one to pass down state or other information to the elements that are wrapped within context.provider in a file structure.
With regard to the React Context API, how would we implement a “consumer” role? A consumer role can be defined by going to the part of the application that requires the information being housed by the context.provider, and wrapping its render in a context.consumer tag. THis will allow the properties that have been passed down by context.provider to be accessed.
Specifically with Context, how are we “wrapping” components to achieve our goals?
by wrapping parts of the file structure within the provider tags, one allows all nested parts fo the structure to potentially have access to the information stored at the context level. Then, this can be accessed by wrapping the renders of those parts where the information needs to be accessed within the .consumer tags that correspond with the .provider tag.
Awesome React Context links
Consume content from (at least) two more of the Awesome React Context links. After some familiarity with React Context, once again share your takeaways from each:
Takeaway 1: Contaxt creates a broadcast mechanism that provides information to any consumer of that information. they are linked via methods, .provider and .consumer
Takeaway 2: one can pass state down as an object through the valiue of the .provider tag.