I'm new to React and functional components and I wanted to create a simple app in which I have a Gallery
component that I'm showing in the app, then I have a button that is supposed to set the state and pass it to the component, this is how it looks:
const App = () => { const [images, setImages] = useState([]); return (<ScrollView><View style={styles.body}><Button title="Press me" onPress={start} /><Gallery imgs={images}/> // Using the state here</View></ScrollView> );};const start = () => { // Create images array here setImages(images); // [ReferenceError: Can't find variable: setImages]};export default App;
But I'm getting the following error: [ReferenceError: Can't find variable: setImages], but the setImages variable is defined in the same file so I don't understand what could be the problem.
Not sure if it matters but I'm using TypeScript.