Simran
@simranjit884
Followers
26
Following
4K
Media
7
Statuses
49
"🚀 Crafting captivating web experiences with JavaScript and React.js ⚛️ | Turning ideas into elegant code | Building the web, one component at a time 💻✨"
Joined February 2015
React Hooks aren't magic—they're just functions. Master these 6 and 80% of your problems disappear. Like the thread? Retweet to help more devs level up 🚀
0
0
0
useMemo- Like useCallback, but for values. const expensiveResult = useMemo(() => compute(), [input]);
1
0
0
useCallback- Memoizes a function so it doesn't get recreated on every render. Useful when passing functions to child components. const memoFn = useCallback(() => doSomething(), [deps]);
1
0
0
useRef- Persistent value that doesn’t trigger a re-render. Great for DOM refs or tracking state without re-renders. const inputRef = useRef(null); inputRef.current.focus();
1
0
0
Dependency array This controls when useEffect runs. useEffect(() => { doSomething(); }, [value]); It runs again only when value changes. Super useful for optimization.
1
0
0
useEffect- Runs after render. Perfect for side effects: – API calls – Event listeners – Local storage useEffect(() => { fetchData(); }, []); The [] means “run once.”
1
0
0
useState- Think of it as giving your component memory. `const [count, setCount] = useState(0);` Now your component can remember count across re-renders.
1
0
0
React Hooks simplified 🧵 If useState and useEffect still confuse you, this thread will fix that—without the fluff.
1
0
1
Less Need for constructor() in Modern React 🔄 With modern #React, you often don’t need the constructor()! You can define state directly in your class components or use functional components with hooks like useState and useEffect. It's cleaner and more concise! ⚛️
0
0
1
Don’t Forget super(props)! 🚨 In React class components, always call super(props) inside your constructor() to initialize "this.props". Missing it causes "this.props" to be undefined, leading to errors. Call super(props) before using this to access state, props, or methods! 🔥
1
0
1
The constructor() is perfect for: - Initializing state: Define the initial values of your state. - Binding event handlers: Bind methods like handleClick to ensure they have access to this. - Props handling: Use super(props) to access this.props in your component.
1
0
0
1️⃣ Set up the initial state. 2️⃣ Bind event handlers to the component instance. 3️⃣ Call 𝐬𝐮𝐩𝐞𝐫(𝐩𝐫𝐨𝐩𝐬) to properly pass props to the parent React.Component. This method is called once, before the initial render! 🖥️ Why Use constructor() in React?🤔
1
0
0
U̲n̲d̲e̲r̲s̲t̲a̲n̲d̲i̲n̲g̲ c̲o̲n̲s̲t̲r̲u̲c̲t̲o̲r̲(̲)̲ i̲n̲ R̲e̲a̲c̲t̲ C̲l̲a̲s̲s̲ C̲o̲m̲p̲o̲n̲e̲n̲t̲s̲ 🚀🚀 In #React, the constructor() method is used to initialize a class component. It allows you to: 🅃🄷🅁🄴🄰🄳 👇
1
0
1
Staying positive and not letting negativity ruin your mood is such an underrated skill.
0
0
0
Server-Sent Events (SSE) allow servers to push real-time updates to the browser over a single HTTP connection which is unidirectional, lightweight, and great for cases like live notifications, stock updates, or news feeds. Look at my post for more details- https://t.co/1HpZ37SFcW
0
1
2
Server-Sent Events (SSE) allow servers to push real-time updates to the browser over a single HTTP connection which is unidirectional, lightweight, and great for cases like live notifications, stock updates, or news feeds. Look at my post for more details- https://t.co/1HpZ37SFcW
0
1
2
𝗦𝗲𝗿𝘃𝗲𝗿-𝗦𝗶𝗱𝗲 𝘃𝘀. 𝗖𝗹𝗶𝗲𝗻𝘁-𝗦𝗶𝗱𝗲 𝗥𝗲𝗻𝗱𝗲𝗿𝗶𝗻𝗴: Key Differences Every Developer Should Know👇 #WebDevelopment #FrontendDevelopment #ClientSideRendering #ServerSideRendering #ReactJS #NextJS #JavaScript #WebPerformance #Frontend #DeveloperTips #Programming
0
0
1
Understanding **Short Polling**: Simple but Inefficient for Real-Time Updates Link- https://t.co/HWP2G7HvbK
0
2
7
The output will be `undefined`. Due to variable hoisting in JavaScript, the `employeeId` inside the function is hoisted to the top of the function scope and initialized with `undefined` before the `console.log` statement is executed.
0
0
0
What will be printed to the console? 🖥️ Reply with your answer! Correct answer is in the comments!! #JavaScript #ProgrammingPuzzle #code #InterviewTips
1
0
1