This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| import { useState,useEffect } from "react"; | |
| let i=0; | |
| function useTodos(n){ | |
| const [todos, setTodos] = useState([]); | |
| const [loadStatus,setStatus]=useState(true); | |
| useEffect(() => { | |
| const Value=setInterval(()=>{ | |
| fetch("https://sum-server.100xdevs.com/todos") | |
| .then(async (res) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { createContext, useContext, useState } from "react"; | |
| // Create a single context for both name and address | |
| const UserContext = createContext(); | |
| function App() { | |
| const [state1,update1] = useState("himashis"); | |
| const [state2,update2] = useState("paikpara"); | |
| return ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useCallback, useMemo, useState } from "react" | |
| import { useEffect } from "react" | |
| import { memo } from "react"; | |
| import { BrowserRouter, Route, Routes, useNavigate } from "react-router-dom"; | |
| import { Dashboard } from "./components/dashboard"; | |
| import { Landing } from "./components/landing"; | |
| function App() { | |
| return <BrowserRouter> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { memo, useCallback, useState } from "react" | |
| import { useEffect } from "react" | |
| import { useMemo } from "react"; | |
| function App() { | |
| const [count,setCount]=useState(0); | |
| var handler=useCallback(()=>{ | |
| console.log("fuck you"); | |
| },[]) | |
| return <div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useMemo, useState } from "react" | |
| import { useEffect } from "react" | |
| /* | |
| let's assume we have two crypto wallets where we already have got the amount of returns | |
| but our regular job payment is not yet done, so after getting the regular salary, the crypto additions | |
| should not happend again, here it is addition / but it may be very expensive operation. | |
| useMemo and useCallbacks are usually useful when there are multiple states, | |
| and change in one may trigger some other expensive operation | |
| */ | |
| function App() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useState } from "react" | |
| import { useEffect } from "react" | |
| //useState is for component re-render whenever state changes | |
| //useEffect also makes fetch/or whatever thing defined when the items defined in [] | |
| //changes | |
| function App() { | |
| const [current,setCurrent]=useState(1);//this is gonna take array of todo(json objects) | |
| return <div> | |
| <button onClick={()=>{ |