Giter VIP home page Giter VIP logo

Comments (26)

Kureev avatar Kureev commented on June 2, 2024 13

那么,它(导航栏)改变了很多,因为在这里的最后一个注释。你使用哪种版本?你能为我们提供一个代码示例?@Yidada

P.S. Google translate FTW!

from react-native-navbar.

toearth avatar toearth commented on June 2, 2024 7

I solve this problem by rendering scenes this way
<Component {...route.passProps} navigator={navigator} route={route} />

from react-native-navbar.

RonakKhandelwal avatar RonakKhandelwal commented on June 2, 2024 4

Solved the Problem though if pass props worked it could have been better feature request?

from react-native-navbar.

Kureev avatar Kureev commented on June 2, 2024

So, in short, you need to pass parameters to your custom components in the navbar, right? It's not implemented yet, but I think I'll try to implement it right now, good catch!

from react-native-navbar.

bakso avatar bakso commented on June 2, 2024

I don't want to pass parameters to my custom components in the navbar, but I want to pass to the next route.Just like the code in navigatorIOS example:

<NavigatorIOS
      initialRoute={{
        component: MyView,
        title: 'My View Title',
        passProps: { myProp: 'foo' },
      }}
    />

and

this.props.navigator.push({
              title: NavigatorIOSExample.title,
              component: NavigatorIOSExample,
              backButtonTitle: 'Custom Back',
              passProps: {topExampleRoute: this.props.topExampleRoute || this.props.route},
            });

from react-native-navbar.

Kureev avatar Kureev commented on June 2, 2024

Navigator is a more low-level thing than NavigatorIOSand it doesn't support that feature out-of-box, but it's not hard to implement. You just need to apply your custom parameters to the NavigationBar in the renderScene. Basically, it's all about re-render NavigationBar with changed props, so you can use setProps or just call render. I'll make an example for that.

from react-native-navbar.

chirag04 avatar chirag04 commented on June 2, 2024

I had the same problem. Look at my last comment here: #12

from react-native-navbar.

Kureev avatar Kureev commented on June 2, 2024

So, have you solved this issue?

from react-native-navbar.

bakso avatar bakso commented on June 2, 2024

No,the problem is blow,I use the navigator to go to next view, but in the next view, I found all the passed props in the next view is null!!!

2015-04-22 10 09 35
2015-04-22 10 09 53

from react-native-navbar.

Kureev avatar Kureev commented on June 2, 2024

@iostalk Thanks for the screenshots, but the most important part is how you renderScene. Can you show me this part? Because all data you pass to Navigator will go to this function.

from react-native-navbar.

bakso avatar bakso commented on June 2, 2024

My render scene:

renderScene: function(route, navigator) {
    var Component = route.component;
    var navBar = route.navigationBar;
    var product = route.product;

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

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

  render: function() {
    return (
      <Navigator
        style={styles.navigator}
        renderScene={this.renderScene}
        initialRoute={{
          component: Entrance,
          navigationBar: <NavigationBar title="Hello~~~"/>,
          product: product
        }}
      />
    );
  }

from react-native-navbar.

Kureev avatar Kureev commented on June 2, 2024

@iostalk ok, this code is totally fine, in your Entrance component you should get access to your product thru this.props.product. Is it Entrance component on the screenshots?

from react-native-navbar.

bakso avatar bakso commented on June 2, 2024

image
I could get the passProps in the router, I figure it out!

from react-native-navbar.

Kureev avatar Kureev commented on June 2, 2024

@iostalk strange, I don't see you passing passProps in this code.

from react-native-navbar.

Yidada avatar Yidada commented on June 2, 2024

我也遇到了同样的问题,使用navigator 的时候,好像它不跟NavigatorIOS一样会传递参数,我想问下您后来是怎么解决这个问题的呢?@iostalk

from react-native-navbar.

Yidada avatar Yidada commented on June 2, 2024

You are so cool for translating my words.Do you mean my react-native version? It's 0.14. and my code seems like this:

onPress: function () {
  var value = this.refs.main.refs.form.getValue();
  if (value) {
    this.props.navigator.push({
      id:'RegPhone2',
      passProps: {phonNum:value}
    })
  }
},

from react-native-navbar.

Kureev avatar Kureev commented on June 2, 2024

I'm not quite sure, but it could be that you have a problem with your refs. If that's not the case, then I'd like to know, where do you use your passProps? I can't find anything about it neither inside official Navigator documentation nor in my API specs.

from react-native-navbar.

Yidada avatar Yidada commented on June 2, 2024

You know, In China we don't have such a good react environment. many apis or functions need to be guess...hahaha ,sorry for my not rigorous. I'll read your API specs maybe I can found my solution.😊

from react-native-navbar.

Yidada avatar Yidada commented on June 2, 2024

May be my question is just how to pass props when we use the Navigator to route my app?

from react-native-navbar.

Kureev avatar Kureev commented on June 2, 2024

Well, I can explain it! When you use <Navigator />, you're able to specify a renderScene function which will decide how to render your scene. It accepts two arguments: route and navigator. In your particular case you're interested in a route. Every time you push a new route, you can pass any extra params to it and then use it to render your component. You can take a look on example I have here. So, in this example I use Navigator's initialRoute property, which specifies the initial route in your application. It may contain any fields you want. In my case it's a component I render inside the scene. But at the same moment you can pass foo: 'bar' and use it thru the route.foo property to inject it into your component.

Hope this helped!

from react-native-navbar.

Yidada avatar Yidada commented on June 2, 2024

It's really helpful for me! I read your example and try it in my app .It works ! Thanks again!😊

from react-native-navbar.

cspkop avatar cspkop commented on June 2, 2024

@Kureev - Thanks for the explanation!

Your idea of passing 'route' as a property of a component in 'renderScene' method solved my problem too. Now I am able to access 'myInfo' value (which i passed using 'passProp' while pushing new scene) in my new scene like this: 'this.props.route.passProps.myInfo'

I hope its the standard way of accessing 'passProps' in new scene.

from react-native-navbar.

zhouyuguo avatar zhouyuguo commented on June 2, 2024

maybe this.props.navigator.navigationContext.currentRoute can solve ur problems.

from react-native-navbar.

mafelix avatar mafelix commented on June 2, 2024

You can also pass the prop through this.props.navigator by creating a new property if it's within the same stack of I believe.

from react-native-navbar.

wujunchuan avatar wujunchuan commented on June 2, 2024

@windhost it work for me!thanks~ 👍 👍

from react-native-navbar.

bingxin-xia avatar bingxin-xia commented on June 2, 2024

It seems like really an early topic from now, current RN version is 0.43, try below
this.props.navigator.push({ component: ProfileUpdate, args: {type: 'birth'} })
and get params in 'ProfileUpdate' page like:
const type = this.props.type

maybe can help some guys like me :)

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.