Controlled Components: React elements which both render content and store state data relating to them– the rendering can then be changed indirectly as state changes are passed to parent components and then subsequently inherit props from the parent based on the state change (via callback functions).
Use case: storing user responses in a form as they are written rather than on submission allows for dynamic rendering per-input (like keystroke).
User input can be targeted as a state of the component and invoked as properties of it, like this.state.value
. This is important for event handling.
?
(Described Here)?
Uses if
else
logic, but syntax is different. Split into three main values, separated by operator and then by a colon:
condition ? true-condition value : false-condition value
Ternary operator allows for more compact code and simple assignment values, like taking this if
else
code:
if(x===y){
` console.log(true);
} else {
console.log(false);
}`
and refactoring to:
x===y ? console.log(true) : console.log(false);