У меня проблема из-за того, что при нажатии кнопки «выбрать» на dpad он распознается 3 раза, а не один раз, и я не могу понять, почему и как это исправить.
Вот вывод консоли каждый раз, когда я нажимаю значок в приложении один раз с помощью dpad:
[Tue Jun 16 2020 19:42:37.491] LOG Pressed Search
[Tue Jun 16 2020 19:42:38.426] LOG Pressed DropDown
[Tue Jun 16 2020 19:42:41.577] LOG Pressed Search
[Tue Jun 16 2020 19:42:41.649] LOG Pressed Search
[Tue Jun 16 2020 19:42:41.654] LOG Pressed Search
[Tue Jun 16 2020 19:42:42.589] LOG Pressed DropDown
[Tue Jun 16 2020 19:42:42.668] LOG Pressed DropDown
[Tue Jun 16 2020 19:42:42.671] LOG Pressed DropDown
[Tue Jun 16 2020 19:42:43.926] LOG Pressed Search
[Tue Jun 16 2020 19:42:44.390] LOG Pressed Search
[Tue Jun 16 2020 19:42:44.550] LOG Pressed Search
[Tue Jun 16 2020 19:50:24.580] LOG Pressed DropDown
[Tue Jun 16 2020 19:51:21.694] LOG Pressed Search
[Tue Jun 16 2020 19:51:21.819] LOG Pressed Search
[Tue Jun 16 2020 19:51:21.822] LOG Pressed Search
[Tue Jun 16 2020 19:51:23.934] LOG Pressed DropDown
[Tue Jun 16 2020 19:51:24.320] LOG Pressed DropDown
[Tue Jun 16 2020 19:51:24.380] LOG Pressed DropDown
Вот код:
class Second extends React.Component {
render() {
return (
<View>
<Appbar.Header>
<Appbar.Action
icon="menu"
onPress={() =>
this.props.navigation.dispatch(DrawerActions.toggleDrawer())
}
/>
<Appbar.Content style={{alignItems: 'center'}} title="" />
<Appbar.Action icon="magnify" onPress={() => console.log('Pressed Search') } />
<Appbar.Action icon="dots-vertical" onPress={() => console.log('Pressed DropDown') } />
</Appbar.Header>
<Text>TV Shows</Text>
</View>
);
}
}