GithubHelp home page GithubHelp logo

Comments (5)

Kureev avatar Kureev commented on July 17, 2024

Hi @aaronksaunders! I'm not sure that I got your case. onNext specifies a callback for "Next" button.

from react-native-navbar.

aaronksaunders avatar aaronksaunders commented on July 17, 2024

the current example assumes that the component loading the new NavBar/Component will handle the next action when I reality it doesn't make sense.

Even in the basic example you have provided, architecturally it makes more sense to have the Example component handle the click event on the menu, not the root component Basic your current example tightly couples the two which I don't this is appropriate... unless I am missing something

class Example extends React.Component {
  render() {
    return (
      <View>
        <Text>Some content</Text>
      </View>
    );
  }
}

class Basic extends React.Component {
  renderScene(route, navigator) {
    var Component = route.component;
    var navBar = route.navigationBar;

    if (navBar) {
      navBar = React.addons.cloneWithProps(navBar, {
        navigator: navigator,
        route: route
      });
    }

    return (
      <View style={styles.navigator}>
        {navBar}
        <Component navigator={navigator} route={route} />
      </View>
    );
  }

  handleNext() {
    alert('Next button click handler');
  }

  render() {
    return (
      <Navigator
        style={styles.navigator}
        renderScene={this.renderScene}
        initialRoute={{
          component: Example,
          navigationBar: <NavigationBar
            title="Initial View"
            onNext={this.handleNext} //<== this should be handled by Example Component
          />
        }}
      />
    );
  }
}

from react-native-navbar.

JonasJonny avatar JonasJonny commented on July 17, 2024
You can use "customNext={<RequiredComponentName />}" 
and there use "this.props.navigator.***" or other logic.

from react-native-navbar.

aaronksaunders avatar aaronksaunders commented on July 17, 2024

@JonasJonny not really following you here. Can you provide a little more detail?

from react-native-navbar.

JonasJonny avatar JonasJonny commented on July 17, 2024

You should use customNext instead of onNext. With customNext you can pass whole component.
In that component you can have render function with TouchableHighlight and onPress function which will call:

// DefaultComponent

<Navigator
                            renderScene={this.renderScene}
                            initialRoute={{
                                component: ***,
                                navigationBar: <NavigationBar
                                    title="***"
                                    customNext={<RequiredComponentName />}
                                    ...
                                />
                            }}
                        />

//RequiredComponentName

goToPage() {
        this.props.navigator.push({
            title: "New title",
            component: AnotherComponentName,
            backButtonTitle: 'Back',
            navigationBar: <NavigationBar
                customNext={<DifferentComponentName/>}
                titleColor="#fff"
                ...}
                />
        });
}


render() {
        return (
            <TouchableHighlight underlayColor="transparent" onPress={this.goToPage}>
                ...
            </TouchableHighlight>
        )
    }

from react-native-navbar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.