我正在尝试使用 react-native-router-flux 设置 react-native-drawer。
我已经按照下面的flux OTHER INFO doc设置了抽屉
import React from 'react-native';
import Drawer from 'react-native-drawer';
import SideMenu from './SideMenu';
import {Actions, DefaultRenderer} from 'react-native-router-flux';
export default class NavigationDrawer extends Component {
render(){
const state = this.props.navigationState;
const children = state.children;
return (
<Drawer
ref="navigation"
open={state.open}
onOpen={()=>Actions.refresh({key:state.key, open: true})}
onClose={()=>Actions.refresh({key:state.key, open: false})}
type="displace"
content={<SideMenu />}
tapToClose={true}
openDrawerOffset={0.2}
panCloseMask={0.2}
negotiatePan={true}
tweenHandler={(ratio) => ({
main: { opacity:Math.max(0.54,1-ratio) }
})}>
<DefaultRenderer navigationState={children[0]} onNavigate={this.props.onNavigate} />
</Drawer>
);
}
}
然后我将抽屉场景放在路由器组件中,如下所示
render() {
return (
<Router>
<Scene key="choice" component={ServiceChoice} title="" hideNavBar />
// some scenes go here
<Scene key="drawer" component={NavigationDrawer} open={false} >
<Scene key="main" tabs={true} >
<Scene
key="map"
component={MapScreen}
title=""
hideNavBar
initial
/>
</Scene>
</Scene>
//some other scenes go here
</Router>
);
}
现在的问题是,从另一个组件,例如 ServiceChoice,如果我这样做Actions.map()
,什么也不会发生。
谁能指出我做错了什么?我可以提供任何其他需要的信息。所有导入也是正确的。
谢谢