Skip to main content

Posts

Showing posts from February, 2024

JS refresher

Function Expression vs Function Declaration vs Anonymous Function in JavaScript //function declaration  function sum(a,b){ return a+b; } //function expression // function expression first need to declare then only we can use let sum = function (a,b){ return a+b; } //fat arrow function const sum = (a,b) => { return a+b; }

React (HOOKS)

 React Hooks:  Feature of class based component into the function based component.  it allows you to use state and other react features without writing the class.  useState : is a React Hook that lets you add a state variable to your component. useState(initialState) const [age, setAge] = useState(42); Ref : https://react.dev/reference/react/useState useEffect :   There is the react lifecycle   useEffect hook called when the component started mounted.  useEffect ( setup , dependencies ? )  useEffect hook need a dependency in the second argument, we can set multiple dependency as an args.  useEffect will run every time whenever the component render Component will re-render if the dependency updated or changed. Again component will run whenever it will unmounted, it means for un-mounting we need to return function from useEffect. Ref CheatSheet Document : https://drive.google.com/file/d/1dko8AZyv94S0Dxwf6h8wFJt9WP_eNvcR/view   ...