-
Requirements
- nodejs,npm
- install nvm
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
- install node & npm
nvm install node
- install nvm
- pnpm
sudo npm i -g pnpm
- nodejs,npm
-
pnpm install
-
npm start
bundler and bootstrapped with - vite
package manager - pnpm -- to save disk space
Library - React
Global State Management - Redux ( redux-toolkit ) /src/store/
Queries State Management - react-query
- Prettier
- Eslint
- GitLens
- Material Icons (*optional)
- Layer 4 - Use react-query hooks in components
- Layer 3 - define react-query hooks in
src/hooks/api
- Layer 2 - fetcher functions
src/services/api
- Layer 1 - request/fetch
src/services/api/request.js
https://github.com/airbnb/javascript/tree/master/react
-
src/components/
./atoms/
- small components which does not depend on any other component../molecules
- components which use atoms../organisms
- coponents which use atoms and molecules
every category folder has an
index.js
file which exports all the components in that folder which are intrun expoterd by theindex.js
file in outer folder. components will always be imported likeimport { SomeComponent } from '/components
not likeimport SomeComponent from '/components/atoms/SomeComponents
src/pages/
page level containers which are accesible from a seperate route.
every component has a folder named exactly as the component name. Component names are in PascalCase.
SomeComponent/
SomeComponent.jsx
SomeComponent.scss
// SomeComponent.jsx
import React from 'react';
export default function SomeComponent({ prop1, prop2 }) {
// STATES & REFS
// EFFECTS
// FUNCTIONS
// PRE-RENDER
// RENDER
return (
<div className="some-component">
{/* classname should be same as component name in - style. to avoid css conflicts */}
<div className="abc">Some</div>
<div className="xyz-q">Component</div>
</div>
);
}
// SomeComponent.scss
// everything starts from the outermost main component class
.some-component {
// every other css goes here in the same nested form as in html
.abc {
display: block;
@include respond(phone) {
display: none;
}
}
.xyz-q {
font-size: 2em;
}
}