What are Class Components?
- Before React 16.8, Class Components were used.
- These components are simple classes.
- All Class components extends parent class Component.
- render() method is used before return() to display output on browser.
- They are very rarely used in React Project.
- Lengthy Code
- Complex
- Create a new file inside src/ with any name (Ex : User.js)
- If you have installed VS Code Extension, then type shortcut rce and press enter.
- Write your logic.
- Open index.js and import the component at top and inside <React.StrictMode> call the component :
<User/>. You can also call the component inside App.js.
INTERVIEW QUESTION
- What is the shortcut way to write class component structure in VS Code?
Answer :
Type rce and press enter.
Comments
Post a Comment