💻 Learn Programming 📆 2023
✅ GitHub Contributions

January - May
- Worked on Redux and Sagas
- Developing Cart and Checkout flow
- Creating reusable and configurable components with atomic design pattern
- Implemented a complete Checkout Re-design with minimal and modern UI
June
Catching up with React 18
Ref vs State
- Updating a reference doesn’t trigger re-rendering, while updating the state makes the component re-render;
- The reference update is synchronous (the updated reference value is available right away), while the state update is asynchronous (the state variable is updated after re-rendering).
- From a higher point of view, references store infrastructure data of side effects, while the state stores information that is directly rendered on the screen.
Work Done
Next.js has two forms of pre-rendering:
Static Generation and Server-side Rendering. The difference is in when it generates the HTML for a page.
- SSG Static Generation is the pre-rendering method that generates the HTML at build time. The pre-rendered HTML is then reused on each request.
- SSR Server-side Rendering is the pre-rendering method that generates the HTML on each request.
Client-side Rendering in Next.js
- When the page loads, fetch external data from the client using JavaScript and populate the remaining parts.
- This approach works well for user dashboard pages, for example. Because a dashboard is a private, user-specific page, SEO is not relevant, and the page doesn’t need to be pre-rendered. The data is frequently updated, which requires request-time data fetching.
Server-side Rendering
// context contains request-specific parameters.
export async function getServerSideProps(context) {
return {
props: {
// props for your component
},
};
}
Dynamic URLs: Next.js allows you to statically generate pages with paths that depend on external data, where each page path depends on external data.

Redux
- App state management library that acts as a Single source of truth
- Helps us implement top-to-bottom data flow for consistent behavior
- Persistent state across applications with Reducers helps transform the state
- As we cannot change the state directly in Redux and it can only be possible with actions, the state changes are predictable
/**
* This is a reducer - a function that takes a current state value and an
* action object describing "what happened", and returns a new state value.
* A reducer's function signature is: (intialState, action) => newState
*
* The Redux state should contain only plain JS objects, arrays, and primitives.
* The root state value is usually an object. It's important that you should
* not mutate the state object, but return a new object if the state changes.
*
* You can use any conditional logic you want in a reducer. In this example,
* we use a switch statement, but it's not required.
*/
function counterReducer(state = { value: 0 }, action) {
switch (action.type) {
case 'counter/incremented':
return { value: state.value + 1 }
case 'counter/decremented':
return { value: state.value - 1 }
default:
return state
}
}
Redux-Saga
An intuitive Redux side effect manager.
Create a Saga
Generator Functions
The functionwith defines a generator function, which returns a Generator object. Generators functions can be exited and later re-entered. Their context (variable bindings) will be saved across re-entrances.
Yield
Yield operator is used to pause and resume a generator function. The yield keyword pauses generator function execution and the value of the expression following the yield keyword is returned to the generator’s caller.
Both call and put are effect-creator functions.
Call
Call is used to create effect description, which instructs middleware to call the promise. call() is a blocking effect, which means that the saga will wait for the promise resolving before moving on to the next step.
Put
Put creates an effect, which instructs middleware to dispatch an action to the store. put(), on the other hand, is a non-blocking effect, which means that the saga can continue to the next step and action will be dispatched within the internal scheduler.
takeEvery vs takeLatest
- takeEvery allows multiple action instances to be started concurrently and their completion order can vary.
- takeLatest allows only one action/task to run at any moment, the previous one will be canceled
Creating the Redux Store and applying Middleware
import { createStore, applyMiddleware } from 'redux'
import createSagaMiddleware from 'redux-saga'
import reducer from './reducers'
import mySaga from './sagas'
// Create the saga middleware
const sagaMiddleware = createSagaMiddleware()
// Mount it on the Store
const store = createStore(
reducer,
applyMiddleware(sagaMiddleware)
)
// Then run the saga
sagaMiddleware.run(mySaga)
Creating SAGA
import { call, put, takeEvery, takeLatest } from 'redux-saga/effects'
import Api from '...'
// Worker saga will be fired on USER_FETCH_REQUESTED actions
function* fetchUser(action) {
try {
const user = yield call(Api.fetchUser, action.payload.userId);
yield put({type: "USER_FETCH_SUCCEEDED", user: user});
} catch (e) {
yield put({type: "USER_FETCH_FAILED", message: e.message});
}
}
function* mySaga() {
yield takeLatest("USER_FETCH_REQUESTED", fetchUser);
}
Dispatch an Action
class UserComponent extends React.Component {
...
onSomeButtonClicked() {
const { userId, dispatch } = this.props
dispatch({type: 'USER_FETCH_REQUESTED', payload: {userId}})
}
...
}
July
TypeScript Revision
- Strongly typed - the variables have fixed types in their life cycle
- Create custom types with interfaces
- TypeScript Basics - Beginner’s Guide
- Interfaces help maintain consistency
- Custom Types, readonly, Array, Union Interfaces, Enum, Tuple, Generics, Type Narrowing
- Learn TypeScript – Full Tutorial Video - FreeCodeCamp, Hitesh Chowdary
- Javascript is dynamically typed i.e. the type of your variable is unknown until it instantiates at run-time which leads to errors. Typescript adds static type support to Javascript which takes care of bugs that are caused by false assumptions of a variable type if you use it right.
FreeCodeCamp Project
- working on Pomodoro Timer with React
- Timer Codepen - [https://codepen.io/abhiramready/full/oNeVJZW]
- Working on the timer function with useInterval and hooks
August
September
October
- Published blog post - Simple and Pure CSS Spinner
- useMemo() = cache result of expensive function calls, recompute when dependencies change
- useCallback() = a new function object is created for every re-render which can hog performance, useCallback() prevents unnecessary re-renders of the children as they’ll be using the same function object.
- React 18 features: Concurrent Rendering, Automatic Batching, Transitions - startTransition, Suspense on the server
- A “higher-order function” is a function that accepts functions as parameters and/or returns a function.
- Intro to React Router - FCC
- HTML vs JSX - FCC
- A Complete Guide to Routing in React
Accessible Unit Testing
ARIA
ARIA attributes aid us to make applications more accessible but the irony is that our code/HTML markup should be semantic enough in the first place so that we need not use/define ARIA exclusively. i.e. applications should be accessible by default.
November
- Working on Next.js basics, App Router
- Learnt and implemented React UI with Tailwind CSS
- Writing unit tests with RTL [React Testing Library] with 100% Coverage
December
- Storbook and pixel perfect UI
- Using AI to write unit tests for components
- Tailwind CSS, Unit test with RTL 100% coverage
- Complete analytics setup and event tracking for a e-commerce application
- Built configurable Next.js components and pages using atomic design pattern