React Flashcards
What is React?
javascript framework for building composable UIs
What are some features of React?
- JSX: ui language that allows us to write html inside of JS
- virtual DOM: bc writing to the DOM is expensive
- composable UI
What is the Virtual DOM
an in memory representation of the real DOM and it syncs against the real DOM. The virtual DOM allows for cheaper and faster and more frequent updates
When does the Virtual DOM sync against the real DOM?
After render() is called but before UI appears on screen
How does the VirtualDOM work?
- when data changes, the entire UI in the vDOM updates
- then React calculates the diff between the vDOM and real DOM
- then the real DOM updates accordingly
What is JSX?
It’s the UI language that allows us to write html with javascript
Difference between state and props
- state is managed by the component
- props are passed into the component
- state re-renders the UI when updated
- props should be immutable and for configuration only
When should you use a callback function in setState() ?
When you have to perform an asynchronous task
What are the 3 phases of the component lifecycle?
- mount
- update
- unmount
What are contexts?
tool to pass data w/o prop drilling. good for things like user auth or preferences
What is a custom hook?
A function that allows us to “hook” into React’s state and lifecycle updates