Hi, I would like to understand better the explanation Mosh gave at the very end of the video 10- Filtering- Displaying Items in the Mastering react course. I would like to know why to change props from prop.property to prop[property]. He mentions it’s done to access the properties ‘dynamically’ but I would like to know why/how. Thanks!
Square bracket notation allows access to properties containing special characters and selection of properties using variables.
prop.property’s property is fixed value, you know it already.
prop[property]'s property is a dynamically-set value, you don’t know until the code ran.
You can only use bracket notation in this case.