import { View, ScrollView, StyleSheet } from 'react-native'
import Heading from './Heading'
import Input from './Input'
class App extends Component {
constructor () {
super()
this.state = {
input value: '',
todos: [],
type: 'All'
}
inputChange (inputValue) {
this.setState({inputValue})
}
}
render () {
const {todos, inputValue, type } = this.state
return (
<View style={styles.container}>
<ScrollView keyboardShouldPersistTaps='always'
style={styles.content}>
<Heading />
<Input
input Value={inputValue}
inputChange={(text) => this.inputChange(text)} />
</ScrollView>
</View>
)
}
}
const styles = StyleSheet.create ({
container: {
flex: 1,
backgroundColor: '#f5f5f5'
},
content: {
flex: 1,
paddingTop: 60
}
})
export default App
"So I have this error that I have tried to fix through disabled eslint and it’s not working. This is my first time using react-native. I’m taking a class and this is for an assignment of mine to create a TodoApp. My teacher gave us the exact code he wanted us to input into VSCode, so we could then make changes to it accordingly for the assignment. I was halfway through his video, and this error kept coming up, but not for him. I have looked all around for an answer and can’t seem to find one. The section of code that gives me a problem in the inputChange (inputValue) and say it’s missing a semicolon. In the video the teacher doesn’t put one and it works completely fine. I’ve done some reading that it could be eslint, but I’ve tried to disable it and it still doesn’t work."
2
Answers
change position of inputChange function from inside of constructor to body of class ( after closing constructor )
Edit
you may name properties incorrect
With this code, you are attempting to define the method
inputChange
inside theconstructor
method, which is not possible. You need to close theconstructor
method definition before defining yourinputChange
method. I recommend taking a closer look at the code your instructor provided. I suspect that on closer inspection you will find one curly brace closing thesetState
function and another curly brace closing theconstructor
method before thatinputChange
method definition starts.