Closed cxk280 closed 6 years ago
I'm trying to pass arguments from a component through to a reducer, but after trying everything I can think of, I am still unable to do so. I'll use the unchanged boilerplate's Counter component as an example.
My current solution has this and works fine:
<TouchableHighlight onPress={increment}> <Text style={styles.text}>+</Text> </TouchableHighlight>
However, I want to pass arguments, which would look like this:
<TouchableHighlight onPress={increment(argument)}> <Text style={styles.text}>+</Text> </TouchableHighlight>
The latter doesn't work. The function is undefined. How do I fix this?
It looks like the answer was to use an arrow function, like this:
(argument)=>increment(argument)
I'm trying to pass arguments from a component through to a reducer, but after trying everything I can think of, I am still unable to do so. I'll use the unchanged boilerplate's Counter component as an example.
My current solution has this and works fine:
However, I want to pass arguments, which would look like this:
The latter doesn't work. The function is undefined. How do I fix this?