Комментарии:
Where can I access the ppts?
ОтветитьHow to add items of array to existing array state object
ОтветитьHi!
Can someone tell me how to use useState with an object with an array attribute??
Why we are pushing an object in line no. 7
Please any can know about it let me know....
Excelente ! Muito Bem Explicado ! ! Parabéns pelos vídeos ! ! !
ОтветитьA less complex way to do this is to use concat method: example below
You can rewrite your addItem method as thus;
const addItem=()=>{
setItems(items.concat({
id: items.length,
value: Math.floor(Math.random() * 10) + 1
}))
}
Thank you vishwas
ОтветитьMy question is that after you append new data to the useState array the component should re-render, In case I have enough number of elements in the array to make it scroll then if i add one more to the useState array then will it re-render and the scroller moves to the top? In both the cases I want to know the reason
Ответитьthank you so much sir
ОтветитьDo not miss the summary !!
ОтветитьSo you don't have to use the prevState setter function when you're spreading the object/array first? Am I right to think that spreading the state also gives the previous state and that's why you don't need it?
Ответитьwhy dont we use previous state in this case while updating the array
Ответить1. setStateVar - will always gets its variable's type brackets.
setName( { } ), setItems( [ ]).
2. if array of items - always - map+arrow function Item + key
3. this video example is array of objects - id (obviously for keys), value - big note:
Thank you very much for these excellent tutorials!
Ответитьhuge thanks for creating this content.. its really helpful 👍 i just figured out something because of YOUR EXISTENCE
Ответить👍 great .
Ответитьdude you are amazing, I was so frustrated until I found this video. Thank you so much
ОтветитьI don't understand English very good, but i understood this video, thanks for helping me😀😀
ОтветитьThank You, Your Video Is Very Helpful.
Ответитьthanks
ОтветитьVery good explanation again. Keep up the good work boss.
ОтветитьAnd if you want to delete an item ?
ОтветитьWhy not simply use "push" ?
Ответитьthank, that helped me a lot !
ОтветитьGreat series
ОтветитьCan we use the push method for append instead of spread op?
Ответитьcan we use 2 d array as a default item? if so how?
Ответитьyou explain theories perfectly
ОтветитьWhile creating a mini project for my university....I was stuck on this for 4 whole days..😭😭😭😭😭 such a basic thing i forgot... I am feeling as if i am the dumbest person alive... Thank you for this vidio it really helped me alot!!!!😭😭😭😭
ОтветитьWow it was good. But here the value of the id property is dependent on the previous array. Are we supposed to use the callback inside the setter?
ОтветитьAppreciating your videos. thanks a lot.
Ответитьthis shows how to add array elements, but how do change an element of array
ОтветитьCurrently I'm working on a project and I'm having an issue with setting the useState dynamically. I'm taking the key from the object return by the api and using them as a key for text field as I'm creating the dynamic curd operation can anyone please help me
ОтветитьGreat, what about delete and update?
Ответитьthank you so much, i was so frustrated while working with arrays in useState hook. You are no less than a savior of students. ❤❤
ОтветитьGod bless u
Ответитьwhat if we wanted to remove the number from the items array? how can we do that using useState? should we do it manually? or there is some way to do it?
ОтветитьYou save me from quiting React; Well explained
ОтветитьYou are my god!
ОтветитьIt was a great video on how we can add items, but how we can remove item from this array? i meant if we want to pop elements? Or can i insert a complete new array to the state variable?
my problem is that if I passed my changing array to the function, then my local array will be modified too.. Only one element will be remained in it
God bless you sir
ОтветитьWhat if you want to delete a specific item from an array and not add something ?
ОтветитьJust wondering, how do you find a specific object to edit? Say id:5 you want to change the value. Is there a way to do that?
Ответитьwhat if i want to add a second value?
Ответитьy do i need a +1 in the 9th line
ОтветитьThank you so much.
ОтветитьWhat about removing element from this array?
And hiw to initialize these with a null array? Do we still have to spread and then set with an empty array?
Would really appreciate if you could explain these things. Thanks