root-two / react-native-drawer

React Native Drawer
MIT License
2.54k stars 392 forks source link

send props to sidemenu at swip #359

Open yeomann opened 6 years ago

yeomann commented 6 years ago

Hi guys, can someone please help me with this? normally in my home screen when someone click on button to open drawer I'm passing successfully my params this way

Actions.refresh({
    key: "drawer",
    open: true,
    userName: "test name",
    userAccountName: "test@something.com"
});

but when I'm swiping I don't see any props such as UserName and userAccountName I see that in my Drawer.js I have onOpen method I tried to some stuff nothing happened. since I was using redux I tried to calling Userinfo from there which worked but it automatically closed the drawer as well. which I assume because of re-rendering.

<Drawer
    type="static"
    ref={ref => (this.drawer = ref)}
    open={state.open}
    onOpen={() => {
    console.log("opened drawer");
    this.props.getUserinfoForNav(); // redux call
    console.log("got some userinfo");
    console.log(this.props.userInfo);
    // Actions.refresh({
    //  key: state.key,
    //  open: true
    //  //userName: this.props.userInfo.userName,
    //  //userAccountName: this.props.userInfo.accountName
    // });
}}

Can someone please help? thanks

Edit: I'm using this lib with react native router flux

yeomann commented 6 years ago

well I did it using flux but is that really the solution. isn't there easy way of doing it?

                onOpen={() => {
                    console.log("opened drawer");
                    //this.props.getUserinfoForNav(); // redux call
                    //console.log("got some userinfo");
                    //console.log(this.props.userInfo);
                    Actions.refresh({
                        key: state.key,
                        open: true,
                        name: this.props.userInfo.name,
                        email: this.props.userInfo.email
                    });
                }}
                onOpenStart={() => {
                    console.log("onOpenStarted");
                    this.props.getUserinfoForNav();
                }}
                onClose={() => {
                    console.log("closed drawer");
                    Actions.refresh({ key: state.key, open: false });
                }}
                content={<SideMenu userData={userData} />}