React JS - Create a New File / Functional Component

  • Right click on src/ folder.

  • Create a new component file (Ex : Demo.js). The first character of component file must be capital.

  • If you have installed VS Code Extension, then type shortcut rfc and press enter.

  • Write your logic.


  • Open index.js and import the component at top and inside <React.StrictMode> call the component : <Demo />

    You can also call the component in App.js.

Github Link :
https://github.com/eramitsinha/React-Dummy/blob/main/src/demo.js

Comments