-
Notifications
You must be signed in to change notification settings - Fork 2
Frontend Guide
- Install the necessary dependencies.
npm install
- To start the development server, execute the following command.
npm start
- To start the cypress test, execute the following command.
npm test
- To start the production build, execute the following command.
npm run build
- Cypress
- Husky
- Lint Staged
- Prettier
- ESLint
- ESLint Airbnb Config
- ESLint Prettier Config
- ESLint Import Plugin
- ESLint JSX a11y Plugin
- ESLint Prettier Plugin
- ESLint React Plugin
We've implemented interceptors to automatically log the API requests and responses through axios in development environment. So, you need to import the custom axios instance instead of directly importing from the axios package.
import axios from "./utils/axiosInterceptor";
In ./utils/axiosInterceptor.js
, change the <Base_URL> to your backend server's base url. For example, http://127.0.0.1:5000
for flask.
Error boundaries are React components that catch JavaScript errors anywhere in their child component tree, log those errors, and display a fallback UI instead of the component tree that crashed.
import ErrorBoundary from "../components/common/ErrorBoundary"
const App = () => {
return (
<div>
<p>Hello, React!</p>
<ErrorBoundary>
<SomeComponent>
</ErrorBoundary>
</div>
)
}
You may wrap top-level route components to display a “Something went wrong” message to the user or you may also wrap individual components in an error boundary to protect them from crashing the rest of the application.
React has some built-in type-checking abilities. To run type-checking on the props for a component, you can assign the special propTypes
property.
import PropTypes from "prop-types";
class Greetings extends React.Component {
constructor(props) {
super(props);
}
render() {
const { name } = this.props;
return <h1>Hello, {name}</h1>;
}
}
Greeting.propTypes = {
name: PropTypes.string
};
A typical redux setup should have the following files in their respective folder.
-
actionsTypes.js
, to declare your different actions in redux. Like this. -
actions.js
, to write your actions. Like this. -
reducer.js
, to manage your reducer's state. Like this.
Once it's done, you've to import the reducer to store.js
and use it in the combineReducers
.
Note: Redux DevTools
is already setup for development and production. You can download the extension for your browser.
Refer the detailed documentation.
Refer the detailed documentation.
Refer the detailed documentation.
Refer the detailed documentation
-
All the files having JSX should have an extension of
.jsx
-
Always de-structure your state & props before using them. Refer to MDN for reference.
-
Use propTypes for all your props to ensure type-checking. Refer to React Docs for reference.
-
Async updates to redux must be handled through redux-thunk.
-
Individual components should be styled using
css modules
. Refer to CRA Docs for reference. -
Always handle error in promises with
catch
method.