useEffect( ) / Callback() / Reducer() / Context() Flashcards
(33 cards)
The dependencies argument of useEffect(callback, dependencies) lets you control when the s____-e_____ runs.
The dependencies argument of useEffect(callback, dependencies) lets you control when the side-effect runs.
If the dependencies are not provided, the side-effect runs after _____ rendering.
If the dependencies are not provided, the side-effect runs after every rendering.
If the dependencies are an empty array [] the side-effect runs _____ after the ______ rendering.
If the dependencies are an empty array []: the side-effect runs once after the initial rendering.
If the dependencies has props or state values [prop1, prop2, …, state1, state2]: the side-effect runs ____ after____ rendering and then only when any d______ value changes.
If the dependencies has props or state values [prop1, prop2, …, state1, state2]: the side-effect runs once after initial rendering and then only when any dependency value changes.
The dependencies argument of the useEffect() lets you catch certain component lifecycle events: when the component has been m______-ed or a specific prop or state value has changed.
The dependencies argument of the useEffect() lets you catch certain component lifecycle events: when the component has been mounted or a specific prop or state value has changed.
M_____ing specifically refers to the process of inserting a component into the DOM for the first time.
Mounting specifically refers to the process of inserting a component into the DOM for the first time.
useEffect(callback, [prop, state]) invokes the callback once after mounting, and again after committing the changes to the ___, if and only if any value in the dependencies array [prop, state] has changed.
useEffect(callback, [prop, state]) invokes the callback once after mounting, and again after committing the changes to the DOM, if and only if any value in the dependencies array [prop, state] has changed.
By using the d________s argument of useEffect(), you control when the side-effect is called, independently from the rendering cycles of the component. Again, that’s the essence of useEffect() hook.
By using the dependencies argument of useEffect(), you control when the side-effect is called, independently from the rendering cycles of the component. Again, that’s the essence of useEffect() hook.
By using the dependencies argument of useEffect(), you control _____ the side-effect is called, independently from the rendering cycles of the component. Again, that’s the essence of useEffect() hook.
By using the dependencies argument of useEffect(), you control when the side-effect is called, independently from the rendering cycles of the component. Again, that’s the essence of useEffect() hook.
If the callback of useEffect(callback, deps) returns a f______, then useEffect() considers that function as an effect cleanup
If the callback of useEffect(callback, deps) returns a function, then useEffect() considers that function as an effect cleanup
If the callback of useEffect(callback, deps) returns a function, then useEffect() considers that function as an effect c_____
useEffect(function callback() => { // Side-effect... return function cleanup() { <<<<<<<< // Side-effect cleanup... <<<<<<<< }; }, dependencies);
If the callback of useEffect(callback, deps) returns a function, then useEffect() considers that function as an effect cleanup
Cleanup works the following way:
A) After i_____ rendering, useEffect() invokes the callback with the side-effect. cleanup function is ___ invoked.
B) On later renderings, before invoking the next side-effect callback, useEffect() i_____s the cleanup function from the previous side-effect execution (to clean up everything after the previous side-effect), then i______s the current side-effect.
C) Finally, after unm_____ing the component, useEffect() invokes the cleanup function from the latest side-effect.
Cleanup works the following way:
A) After initial rendering, useEffect() invokes the callback with the side-effect. cleanup function is not invoked.
B) On later renderings, before invoking the next side-effect callback, useEffect() invokes the cleanup function from the previous side-effect execution (to clean up everything after the previous side-effect), then invokes the current side-effect.
C) Finally, after unmounting the component, useEffect() invokes the cleanup function from the latest side-effect.
useCallback(callbackFun, deps) is helpful when given the same dependency values as deps, the hook returns the same function instance between renderings (aka m______tion):
useCallback(callbackFun, deps) is helpful when given the same dependency values as deps, the hook returns the same function instance between renderings (aka memoization)
Context.Provider component available on the context instance is used to provide the context to its ____ components, no matter how deep they are.
Context.Provider component available on the context instance is used to provide the context to its child components, no matter how deep they are.
Context.P____ component available on the context instance is used to provide the context to its child components, no matter how deep they are.
Context.Provider component available on the context instance is used to provide the context to its child components, no matter how deep they are.
a way to use useContext()
is with a render f____ supplied as a c____ to Context.Consumer special component available on the context instance
a way use useContext()
is with a render function supplied as a child to Context.Consumer special component available on the context instance
import { Context } from './context'; function MyComponent() { return ( <Context.Consumer> {value => <span>{value}</span>} </Context.Consumer> ); }
a way to use useContext()
is with a render function supplied as a child to Context.C____ special component available on the context instance
a way use useContext()
is with a render function supplied as a child to Context.Consumer special component available on the context instance
import { Context } from './context'; function MyComponent() { return ( <Context.Consumer> {value => <span>{value}</span>} </Context.Consumer> ); }
You can have how many consumers for a single context?
You can have as many consumers as you want for a single context.
If the context value changes (by changing the value prop of the provider <Context.P____ value={value} />), then all consumers are immediately notified and re-rendered.
If the context value changes (by changing the value prop of the provider <Context.Provider value={value} />), then all consumers are immediately notified and re-rendered.
If the context value changes (by changing the value prop of the provider <Context.Provider value={value} />), then all consumers are immediately notified and re-r_____-ed.
If the context value changes (by changing the value prop of the provider <Context.Provider value={value} />), then all consumers are immediately notified and re-rendered
If the consumer isn’t wrapped inside the provider, but still tries to access the context value (using useContext(Context) or <Context.Consumer>), then the value of the context would be the d_ v_ argument supplied to createContext(d_) factory function that had created the context.</Context.Consumer>
If the consumer isn’t wrapped inside the provider, but still tries to access the context value (using useContext(Context) or <Context.Consumer>), then the value of the context would be the **default value** argument supplied to createContext(**defaultValue**) factory function that had created the context.</Context.Consumer>
context can hold:
g___ state
theme
application c______
a______-d user name
user s_____
preferred language
a collection of s_____s
context can hold:
global state
theme
application configuration
authenticated user name
user settings
preferred language
a collection of services
The simplest way to pass data from a parent to a child component is when the parent assigns p____s to its child component
The simplest way to pass data from a parent to a child component is when the parent assigns props to its child component
function Application() { const userName = "John Smith"; return <UserInfo userName={userName} />; } function UserInfo({ userName }) { return <span>{userName}</span>; }
The React Context API is s______less by default and doesn’t provide a dedicated method to update the context value from consumer components.
The React Context API is stateless by default and doesn’t provide a dedicated method to update the context value from consumer components.