react-class-components Flashcards
1
Q
How do you create “class” component in React?
A
start with class keyword, class name, the name has to start with capitalized letter, followed by extends React.Component, curly braces. And in the code block, you must define a render method. Example: 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.prop