Skip to content

Declare customValue type for passing an arbitrary value to touchables #890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 11, 2020

Conversation

ethanshar
Copy link
Collaborator

@ethanshar ethanshar commented Aug 11, 2020

WOAUILIB-1006
Today our TouchableOpacity's onPress callback support passing back the props the user pass.
This is very useful cause it helps avoid passing inline callback
So instead of doing this

<TouchableOpacity someValue={1}  onPress={(props) => doSomething(props.someValue)} />

You can do

<TouchableOpacity someValue={1}  onPress={doSomething} />
...
doSomething({someValue}) => {...}

After migrating to TS this pattern has become an issue, because when a user pass an arbitrary prop like someValue typescript throws an error.
The new customValue prop purpose is to have a dedicate prop for passing these values.

@ethanshar ethanshar merged commit 8401a91 into master Aug 11, 2020
@ethanshar ethanshar deleted the feat/Touchable_arbitraryValue branch September 21, 2020 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants