React-native-router-flux: onPress button don't open my drawer

Created on 9 Nov 2016  路  2Comments  路  Source: aksonov/react-native-router-flux

Version

  • react-native-router-flux v3.36.0
  • react-native v0.35.0
  • react-native-drawer v.2.3.0

Expected behaviour

Styled navbar with custom buttons which opens the drawer on press.

Actual behaviour

Styled navbar, but the menu button press return nothing (error or anything).

Steps to reproduce

index.android.js
`export default class relevanti extends Component
{
logoButton = () => (
containerStyle={$style.header_logo}
onPress={() => { Actions.profile.call(); }}
>


);

profileButton   = () => (
    <Button>
        <IonIcon name="md-person" size={25} color="#FFF" />
    </Button>
);

sidebarButton   = () => (
    <Button onPress={() => { Actions.refresh({ key: 'drawer', open: true }); }}>
        <MaterialIcon name="menu" size={25} color="#FFF" />
    </Button>
);

backButton      = () => (
    <Button onPress={() => { Actions.main.call(); }}>
        <MaterialIcon name={ I18nManager.isRTL ? 'chevron-right' : 'chevron-left' } size={25} color="#FFF" />
    </Button>
);

render() {
    return (
        <Router>
            <Scene key="root">
                <Scene key="drawer" component={Sidebar} open={true}>
                    <Scene key="drawer_root"
                        navigationBarStyle={$style.header}
                        renderTitle={this.logoButton}
                    >
                        <Scene
                            key="main"
                            component={MainView}
                            renderLeftButton={this.sidebarButton}
                            renderRightButton={this.profileButton}
                            type="reset"
                            initial={true}
                        />

                        <Scene
                            key="profile"
                            component={ProfileView}
                            renderLeftButton={this.sidebarButton}
                            renderBackButton={this.backButton}
                        />
                    </Scene>
                </Scene>
            </Scene>
        </Router>
    );
}

}`

sidebar.js (drawer)
`class Sidebar extends Component
{

componentDidMount() {
    Actions.refresh({key: 'drawer', ref: this.refs.navigation});
}

render() {
    const state     = this.props.navigationState;
    const children  = state.children;

    return (
        <Drawer
            ref="navigation"
            type="overlay"
            content={<SidebarInit />}
            tapToClose={true}
            openDrawerOffset={0.2}
            styles={drawerStyles}
            tweenHandler={(ratio) => ({
                main: { opacity:Math.max(0.54, 1-ratio) }
            })}
        >
            <DefaultRenderer navigationState={children[0]} onNavigate={this.props.onNavigate} />
        </Drawer>
    );
}

}`

Most helpful comment

Well, finally found my stupid fault.
The import of my Sidebar was under curly brackets, after changing this - worked perfect.

Although, I'm thinking that the documentation of the combined drawer and flux is a little bit bad, so I'll try as soon as I can to make a small tutorial.

All 2 comments

i have the same problem

Well, finally found my stupid fault.
The import of my Sidebar was under curly brackets, after changing this - worked perfect.

Although, I'm thinking that the documentation of the combined drawer and flux is a little bit bad, so I'll try as soon as I can to make a small tutorial.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jgibbons picture jgibbons  路  3Comments

rafaelcorreiapoli picture rafaelcorreiapoli  路  3Comments

sreejithr picture sreejithr  路  3Comments

sylvainbaronnet picture sylvainbaronnet  路  3Comments

fgrs picture fgrs  路  3Comments