Search smart in VSCode using regexI was in the middle of writing a unit test case for some service built-in JavaScript using Jest. We need to mock data instead of actually having a connection using a database instance. In particular model response json data, I need to search for a pa...Nov 6, 2023 · 1 min readnsblog.hashnode.dev
TIL #4: Why React Component re-renders in Strict modeToday, while doing my day-to-day tasks, I come to observe that my API call in useEffect runs twice, I knew that it was re-rendering because of the local state changes inside the component, but it was not the case, in the first place the useEffect was...1THJul 10, 2023 · 1 min readnsblog.hashnode.dev
What is Immutability in React?While working with React library, you already understand well that whenever any props value or state of that particular component changes then it re-renders and displays the latest data to the screen. It has been also observed that any child componen...3MLOFeb 1, 2022 · 3 min readnsblog.hashnode.dev
TIL #3: Early Returns/Guard Clauses in JavaScript (and React)Early Return Early Return is a pattern that suggests we avoid nested if-else statements by checking the preconditions and return or throw as early as possible. Usually, Early Return is also called Gaurd Clause or Bouncer Pattern. Contrived Example //...6LOKDec 14, 2021 · 1 min readnsblog.hashnode.dev
TIL #2: How to Conditionally Add Props to a React Component?Using Inline Ternary Operator Conditionally Spreading the Object Properties We can use ternary or logical && operator, along with the spread operator, to conditionally add props to a component like so: <Tooltip message={message} // usin...1RDec 9, 2021 · 1 min readnsblog.hashnode.dev