React Components Flashcards
What is a React.Component?
Is a simple javascript class that must be inherited to write a react component.
How parameters are sent to the component?
Via the props parameter
How to have the vscode html helpers even on javascript files?
By configuring the emmet settings.json to:
"emmet.includeLanguages": { "javascript": "html" }
What does the render method returns?
a React element
How to interpolate javascript in a JSX structure?
By the use of the curly brackets { }
What is the method that is always called when you create a react component?
render(){
}
How to do string interpolation on javascript?
the string needs to be defined with `` and the var with ${ }
alert(this is the flashcard no ${number}.
Where the react component keeps values to be used later on?
In the react’s superclass state property
What to do with the javascript class when you need to implement the constructor?
You need to call super(props) in order to call React’s constructor - normal oop
Should all react components’ constructor start with a super(props)?
Yes… All React component classes that have a constructor should start with a super(props) call.
What happens when you call setState in a react component?
It refreshes itself and also all the child components.
What is the React Developer Tools?
React Developer Tools is a tool that allows you to inspect a React tree, including the component hierarchy, props, state, and more. To get started, just open the Firefox devtools and switch to the “⚛️ Components” or “⚛️ Profiler” tab.
What is a controlled component?
Is when a component does not have its own state, instead it receives delegates to call and inform changes to the parent component.
What is immutability in React?
Is when instead of changing the object’s data, you create a new instance of object and replace the existing object with the updated one.
Why is immutability important?
Complex features become simpler (time travel) and also the change detection mechanism works best once the object instance changes (instead of its content only).