Skip to content

Commit 19c2a3e

Browse files
committed
docs: improved navigation.push example in readme
1 parent 2e940f3 commit 19c2a3e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,22 @@ import { SharedElement } from 'react-navigation-sharedelement';
4141
class ListScreen extends React.Component {
4242
renderItem(item) {
4343
return (
44-
<TouchableOpacity onPress={() => this.props.navigation.push('Detail', {sharedElements: [`itemPhoto.${item.id}`]})}
44+
<TouchableOpacity onPress={() => this.onPressItem(item)}>
4545
<SharedElement id={`itemPhoto.${item.id}`}>
4646
<Image source={...} />
4747
</SharedElement>
4848
</TouchableOpacity>
4949
)
5050
}
51+
52+
onPressItem(item) {
53+
const { navigation } = this.props;
54+
navigation.push('Detail', {
55+
sharedElements: [
56+
`itemPhoto.${item.id}`
57+
]
58+
});
59+
}
5160
}
5261
```
5362

0 commit comments

Comments
 (0)