react-class-components Flashcards
1
Q
How do you create “class” component in React?
A
Using the “class” keyword, followed by the name of the component, followed by the “extends” keyword, followed by the “React.component”. On the next line, enter “render()” and the opening curly brace of the code block. Then enter the code block.
ex. class Welcome extends React.Component { render() { return < h1 > Hello, { this.props.name } < /h1 >; } }
2
Q
How do you access props in a class component?
A
“this.props.(name of property you want to access)”