+ 7

I want to render a list with react

This is my try so far. Now I don't want to replace the items but to add https://code.sololearn.com/Wq1qqGgoyWBj/?ref=app

29th Aug 2020, 12:08 PM
Oma Falk
Oma Falk - avatar
13 odpowiedzi
+ 7
Oma, this is where State comes in play. https://code.sololearn.com/Wk6CiQedMyfK/?ref=app
29th Aug 2020, 1:36 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 6
Something like this ? function Exc(){ return(<React.Fragment><ul>{ excuses.map(el=>( <li >{el}</li> )) } </ul> </React.Fragment>); } function wand(){ var el = <Exc/>; ReactDOM.render(el , document.getElementById('root')); } var theWand = setTimeout(wand, 500)
29th Aug 2020, 12:30 PM
Abhay
Abhay - avatar
+ 6
Virtual DOM Is what makes react unique and better, I guess. It uses these algorithms and compares two objects and updates only that part which is being updated. So, even if we re render the list multiple times, it won't have to print them again and again and again. My views on jQuery is clear shot, if you know modern JS good enough, jQuery is not needed.
29th Aug 2020, 4:05 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 4
Abhay not so bad.. But now I always render the whole Fragment. Can I simply add?
29th Aug 2020, 12:40 PM
Oma Falk
Oma Falk - avatar
+ 4
Okay, so i modified it in a way that now it will add things to it.
29th Aug 2020, 2:29 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 3
🔫 Rick Grimes yep... Now I have to understand..but yes...
29th Aug 2020, 2:36 PM
Oma Falk
Oma Falk - avatar
+ 2
Abhay right I do. But I re-render the list. it might be optimized.
29th Aug 2020, 1:15 PM
Oma Falk
Oma Falk - avatar
+ 2
🔫 Rick Grimes now add the items instead of replace
29th Aug 2020, 2:13 PM
Oma Falk
Oma Falk - avatar
+ 1
Abhay after an interval
29th Aug 2020, 1:12 PM
Oma Falk
Oma Falk - avatar
+ 1
Oma Falk but you are doing that already or am I missing something!
29th Aug 2020, 1:13 PM
Abhay
Abhay - avatar
+ 1
🔫 Rick Grimes I wonder if react is the right choice. As far as I understood it works with a virtual DOM. Maybe JQuery is the better choice? (Just in theory...I made it as react training) Abhay ? What would u say?
29th Aug 2020, 3:52 PM
Oma Falk
Oma Falk - avatar
+ 1
Oma Falk as far as i know jQuery makes things simpler by providing functions for tasks that we won't need to write in vanilla js again but react works on virtual dom updating only those elements whose states changes instead of updating the whole dom again which is really good for complex apps,and also provides component structure that can be reused and make things simple by providing use of jsx but to me it looks really difficult to make something different or simple but since I started with react few days ago so i can't tell much about the benefits or uses
29th Aug 2020, 4:24 PM
Abhay
Abhay - avatar
0
Oma Falk like you are doing right now ,adding of items after some interval ? or adding them on some click!
29th Aug 2020, 1:02 PM
Abhay
Abhay - avatar