Edit Article
Title
Description
This blog is a collection of my learnings from building Echoes, till yet.
Markdown
## New Packages 1. [`bcryptjs`](https://www.npmjs.com/package/bcrypt): This npm package can be used to hash passwords before storing them in the database. 2. [@redux/toolkit](https://redux-toolkit.js.org/), [react-redux](https://react-redux.js.org/) and [redux-persist](https://www.npmjs.com/package/redux-persist) : Set of libraries to manage and persist application state. ## Backend - If you `export defualt` something from a js file, then while importing that thing you can name it anything. Exporting file: *auth.route.js* `export default router` Importing file: *index.js* `import authRoutes from './routes/auth.route.js'` Notice how `router` is imported by the name `authRoutes`. - However, if you just `export` something from a js file, then while importing that thing you need to use the same name. Exporting file: `auth.controller.js` `export const signup = async ()` Importing file: `auth.route.js` `import { signup } from '../controllers/auth.controller.js'` - In a POST request if you are sending JSON data as the request body then you need to specify this statement `app.use(express.json())` so that the JSON data reaches your middleware functions. - The default form behavior is that whenever submit is hit, the form would get refreshed, in order to prevent this default behavior we can use: `const handleSubmit = async (e) => e.preventDefault()` - You can use the `onChange` event handler on text inputs to detect change in real time and perform validation. ## Frontend - When using `redux-persist`, you might encounter issues with the serializability check middleware because `redux-persist` can store non-serializable values (like promises) in the state. To avoid these issues, you can disable the serializability check middleware.
Cancel
Save