I tried to use BottomNavigation with React Hooks, useState.
But i am getting error while trying to change route.
Anyone tried before?
I write it like this and it's working fine
const [nav, setNav] = useState({
index: 0,
routes: [
{ key: 'music', title: 'Music', icon: 'album' },
{ key: 'albums', title: 'Albums', icon: 'album' },
{ key: 'recents', title: 'Recents', icon: 'history' },
],
});
<BottomNavigation
navigationState={nav}
onIndexChange={(index) => _handleIndexChange(index)}
renderScene={_renderScene()}
/>
function _handleIndexChange(index) {
setNav({ ...nav, index })
};
function _renderScene() {
return BottomNavigation.SceneMap({
music: ResumeFeed,
albums: ResumeFeed,
recents: ResumeFeed,
});
}
Good luck
Most helpful comment
I write it like this and it's working fine
const [nav, setNav] = useState({ index: 0, routes: [ { key: 'music', title: 'Music', icon: 'album' }, { key: 'albums', title: 'Albums', icon: 'album' }, { key: 'recents', title: 'Recents', icon: 'history' }, ], });<BottomNavigation navigationState={nav} onIndexChange={(index) => _handleIndexChange(index)} renderScene={_renderScene()} />function _handleIndexChange(index) { setNav({ ...nav, index }) };function _renderScene() { return BottomNavigation.SceneMap({ music: ResumeFeed, albums: ResumeFeed, recents: ResumeFeed, }); }Good luck