question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use it with react-native-router-flux

See original GitHub issue

Hi, can you please show an example of how to use your component with react-native-router-flux?

Should I use it like this?

import {Scene, Router} from 'react-native-router-flux';

class App extends React.Component {
  render() {
    return <Router>
      <Scene key="root">
        <Scene key="login" component={Login} title="Login"/>
        <Scene key="register" component={Register} title="Register"/>
        <Scene key="home" component={Home}/>
      </Scene>

     // Within your render function.
     // Include the MessageBar once within your top View element
     // Make sure you add the MessageBar at the very bottom of your master component, then it will be           displayed over all other components
     <MessageBarAlert ref="alert" />

    </Router>
  }
}

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
heraryacommented, Feb 7, 2018
1reaction
johanmiccommented, Jan 31, 2017

im using with react-native-router-flux and have no problems with it

class AppRouter extends Component {
  constructor(){
    super()
    this.state = {shouldReload:false}
  }
  componentWillReceiveProps(nextProps) {
    this.setState({shouldReload:true})
  }
  componentDidMount() {  
    MessageBarManager.registerMessageBar(this.refs.alert);

  }
  componentWillUnmount() {
    MessageBarManager.unregisterMessageBar();
  }
  showAlert(alert) {
    MessageBarManager.showAlert(alert);
  }
  render() {
    const { loggedIn } = this.props
    return (
      <View style={styles.container}>
      <RouterWithRedux
        navigationBarStyle={ //
          {
            marginTop:-20,
            backgroundColor:colors.primaryDark,
            borderBottomWidth:0,
          }
        }
        renderBackButton={(nav) => {
            return nav.navigationState.index ? (
                <TouchableOpacity onPress={Actions.pop} style={{height:40, width: 40, margin:10, marginTop:5}}>
                    <Icon name="ios-arrow-back" size={20} color="white"  />
                </TouchableOpacity>
            ) : null;
        }}
        titleStyle={
          {color:colors.white}
        }
        showAlert={this.showAlert}
      >
      <Scene key="root">
            ...scenes            
      </Scene>
      </RouterWithRedux>
      <MessageBarAlert ref="alert" />
      </View>
    )
  }
}

then i call this.props.showAlert( {your alert} ) whenever i need it. not very reduxy but does the job.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using react-native-router-flux | by Spencer Carli | Differential
Setup. First thing we'll do is set up our react native project and then install the react-native-router-flux package.
Read more >
aksonov/react-native-router-flux: The first declarative ... - GitHub
react -native-router-flux is a different API over react-navigation . It helps users to define all the routes in one central place and navigate...
Read more >
react-native-router-flux examples - CodeSandbox
Learn how to use react-native-router-flux by viewing and forking example apps that make use of react-native-router-flux on CodeSandbox.
Read more >
React Native - Router - Tutorialspoint
To begin with, we need to install the Router. We will use the React Native Router Flux in this chapter. You can run...
Read more >
How to use the react-native-router-flux.Actions.create function ...
How to use the react-native-router-flux.Actions.create function in react-native-router-flux · To help you get started, we've selected a few react-native-router- ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found