tyriem / REACT

VSC ReACT JS Commits
0 stars 0 forks source link

ISSUE: STATE OF ARRAY NOT UPDATING WITH NEW INPUT #2

Closed tyriem closed 3 years ago

tyriem commented 3 years ago

https://github.com/tyriem/REACT/blob/8997951a7682f9601a0dfaa4e5c126d91e92094c/app/src/Intro%20to%20REACTJS%2017-2%20-%20JSON%20OBJECTS%20%2B%20ARRAYS%20ASSIGNMENT%20%2B%20STATE.tsx#L95

@tyriem @aaronksaunders @aaron@clearlyinnovative.com

aaronksaunders commented 3 years ago

you cannot create a state variable like this... it should be

 const [ classArray, setClassArray] = React.useState(); 

see completed example here - https://stackblitz.com/edit/react-zwomkm?file=src/ListDisplay.js

tyriem commented 3 years ago

you cannot create a state variable like this... it should be

 const [ classArray, setClassArray] = React.useState(); 

see completed example here - https://stackblitz.com/edit/react-zwomkm?file=src/ListDisplay.js

Understood, will correct and revert. Thank you for your suggested solution.

tyriem commented 3 years ago

Solution implemented as per suggestion and condensed to singular .TSX