function
more effecience and less complexity, to deal with multiple contexts
The best way to test Context is to make our tests unaware of its existence and avoiding mocks. We want to test our components in the same way that developers would use them (behavioral testing) and the way they would run in our applications (integration testing).
Behavioural Testing is a testing of the external behaviour of the program, also known as black box testing. It is usually a functional testing.
This term refers to the situation or circumstances in which an event occursβ¦the particular setting in which the event occurs. For example, when attempting to understand behavior, it is important to look at the situation or circumstances present at the time of the behavior.
Context provides a way to pass data through the component tree without having to pass props down manually at every level.
Context is primarily used when some data needs to be accessible by many components at different nesting levels.
const MyContext = React.createContext(defaultValue);
const { addAlert } = useSnackBars()
>...
>addAlert('Your profile is updated!')