Generate react things with just a command.
For beginnings, lets install the npm package.
npm i -g dx-react
Give sudo permissions if you are on Linux/MacOS
Generate a new component from your terminal
dx-react component YOUR_NAME
This creates a folder with the given name and adds index.js
file and YOUR_NAME.css
file.
dx-react file YOUR_NAME
This just creates YOUR_NAME.js
file in your components file.
Rules :
-
Only Alphabets are allowed for a name
-
No Number, Special character, spaces are allowed for a name
-
A
Component
folder is created if not exists and all the generated files are stored here. -
The given name is converted to lowercase to process
Generate a router file
dx-react router
No name required. This command will generate router.js
file in your src
folder.
Rules
-
Import components to your
router.js
file -
Navbar template is added. Add links as you need
-
Routes template is added. Uncomment and declare routes
-
Once done, change the below code in your
index.js
file.
import Router from './router';
ReactDOM.render(<Router />, document.getElementById('root'));
Generate a form template with validations, onchange events and submit function
dx-react form YOUR_NAME
This components folder with YOUR_NAME
folder and index.js
and YOUR_NAME.css
dx-react form YOUR_NAME
This creates just a file with YOUR_NAME.js
in your components folder
All component rules apply here.