React Flashcards
What is React?
Framework for creating interactive UI for webpages
What is a React element?
an object representation of a virtual DOM node.
How do you mount a React element to the DOM?
render( )
How do you mount a component to the DOM?
render ( )
What are props in React?
a type of object where the value of attributes of a tag is stored.
How do you pass props to a component?
How do you write JavaScript expressions in JSX?
In { }
What are controlled components?
What two props must you pass to an input for it to be “controlled”?
What is a React Effect?
A way to tell React that your component needs to do something after render/mount.
When should you use an Effect and when should you not use an Effect?
Effects are an escape hatch from the React paradigm. They let you “step outside” of React and synchronize your components with some external system like a non-React widget, network, or the browser DOM. If there is no external system involved (for example, if you want to update a component’s state when some props or state change), you shouldn’t need an Effect.
When do Effects run?
Without a dependency -> Every render. With a an empty array -> On mount With dependencies -> On mount and if dependency has changed.
What function is used to declare an Effect?
useEffect( ( ) => { } )
When does the clean up function run
Before the effect is run again and when you unmount.
What does fetch() return?
A Promise that resolves to a Response object.