Dash
June 24, 2021, 11:49pm
1
In Course 10 - Building ImageInputList (Basics)
I am currently stuck in rendering images.
Code in App.js
const handleAdd = (uri) => {
//setImageUris([…imageUris, uri]); - Original Code from Mosh
setImageUris((imageUris) => […imageUris, uri]); (my Code)
};
I added the change from a user in the forum who claims to have solved the issue.
But I still get an error.
Any help will be much appreciated. Thanks in advance.
Dash
June 25, 2021, 6:04am
2
The useState should use an empty array.
This is how I solve it.
const [imageUris, setImageUris] = useState([] ); - My updated code
const [imageUris, setImageUris] = useState(); Original
setImageUris([…imageUris, uri]) Works Fine.
I tried this please it isn’t working
const [imageUris, setImageUris] = useState([]);
const handleAdd = (uri) => {
setImageUris([...setImageUris, uri]);
};
Here's my code