How to Track Old State vs New State in React with useRef

  Рет қаралды 2,466

Coders Campus

Coders Campus

Күн бұрын

Пікірлер: 4
@TheFenzakosu
@TheFenzakosu Жыл бұрын
Spent about 4 -5 hours yesterday because of that bug in previous lesson, didn't know why that happened . Thanks for solving this issue!
@bagathijogarao8064
@bagathijogarao8064 Жыл бұрын
const handleSubmit = async () => { if (assignment) { const newAssignment: Assignment = {...assignment}; if (assignment.status === assignmentStatuses?.[0].status) newAssignment.status = assignmentStatuses?.[1].status; await updateAssignment.mutate(newAssignment) } } this also works fine😅
@ishtakkar3256
@ishtakkar3256 6 ай бұрын
Just changed my save function like this: const save = async () => { const data = await ajax(`/api/assignments/${assignmentId}`, "PUT", jwt, { ...assignmentData, status: assignmentStatuses[1].status, }); setAssignment(data); }; This will have to be further refined if we wish to change the status later in the future to something other than "Submitted".
Streamlining our Assignment Creation Process
31:20
Coders Campus
Рет қаралды 814
Learn React Hooks: useRef - Simply Explained!
12:42
Cosden Solutions
Рет қаралды 119 М.
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 61 МЛН
IL'HAN - Qalqam | Official Music Video
03:17
Ilhan Ihsanov
Рет қаралды 700 М.
Every React Concept Explained in 12 Minutes
11:53
Code Bootcamp
Рет қаралды 885 М.
Exploring the Async Behavior of React's useState Hook
13:02
Josh tried coding
Рет қаралды 7 М.
Speed Up Your React Apps With Code Splitting
16:50
Web Dev Simplified
Рет қаралды 397 М.
useRef hook in reactjs | Easiest way
19:44
Hitesh Choudhary
Рет қаралды 84 М.
I tried React and it Ruined My Life
1:19:10
Tsoding Daily
Рет қаралды 158 М.
ALL React Hooks Explained in 12 Minutes
12:21
Code Bootcamp
Рет қаралды 177 М.
Learn React Hooks: useEffect - Simply Explained!
14:07
Cosden Solutions
Рет қаралды 178 М.
The standard library now has all you need for advanced routing in Go.
13:52
Learn useState In 15 Minutes - React Hooks Explained
15:45
Web Dev Simplified
Рет қаралды 1,2 МЛН