Похожие чаты

When do you have a situation where you manually set

an array index? Use splice or push If you must be alter the array

7 ответов

34 просмотра

My problem is that I'm not doing that :)) let history = [] const [shapes, setShapes] = useState([]) const handleUndo = useCallback(() => { if (!history.length) return history.pop() let isFound = false for (let i = shapes.length - 1; i >= 0; i--) { if (!history[history.length - 1]) return if (shapes[i].id === history[history.length - 1].id) { isFound = true shapes[i] = history[history.length - 1] break } } if (!isFound) { shapes.pop() } setShapes(shapes) }, [shapes])

Misan- Автор вопроса
Masoud
My problem is that I'm not doing that :)) let...

Oh they use the index as identifier for another array. Why not use the id property? It seems like a duplicated check. Unnecessary complexity

Masoud
My problem is that I'm not doing that :)) let...

heyyo how do you know when to use () or {} in code? [] is for array but I get confused with other brackets

12 Nothing
heyyo how do you know when to use () or {} in code...

The code that you saw above is react not vanila js :)

12 Nothing
heyyo how do you know when to use () or {} in code...

it's language syntax, you have to learn it according to the docs

12 Nothing
Ok i guess i shud focus more on docs ...

Learn primitive types vs reference types conditionals, guard clauses loops functions, passing functions to functions, returning functions from functions, arrow functions, iife array methods prototype chain event loop Destructing, spread Dom manipulation Promises, async await Make something small with it then you should be ready for a framework

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта