React JS Render Form With Dynamic Data From Backend API
including field validations
We need to plot a form whose entire fields are coming from the backend. Since the fields are not known in advance, we cannot add them statically. The data about each field, such as its id to save with, name, validations, etc. all comes in the API response too.
For the given scenario, I have used React Hook Form. The demo and example code for a dynamic questionnaire is shared below.
[Read More]React Docs Ebooks
In EPUB, MOBI, and PDF formats
JavaScript: Change the Behavior of a Class Method at Runtime
Useful Strategy to Perform Different Operations Without Repeated if Else or Switch Statements
Recently I came across a problem where I needed to perform two different sets of operations throughout the application for two types of users. The trouble was:
- I needed to turn on or off an operation based on certain condition, which would only be known once the user was logged in, not at the beginning.
React JS Code Review Checklist
A handy guide to review a pull request
This post provides a checklist to review a React JS application code. For many issues, especially related to personal taste like semicolon or arrow vs traditional function, and things like propTypes, we can simply configure linters such as ESlint and Prettier to automatically detect and force us to resolve the warnings. We can furthermore make these linting fixes mandatory on commits (such as with Husky hooks) or PR merges (with CI/CD tools such as Github Actions).
[Read More]Remove Eslint Warnings For Dynamic Imports
import/no-dynamic-require & global-require
GOF Design Patterns in React JS
In this post I try to identify some of the Gang of Four (GOF) design patterns used, or can be used, in React JS applications. Most patterns I list down are not strictly React's, but belong to JavaScript, so they're equally applicable in other frameworks too, such as Vue and Angular.
[Read More]