Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected behaviour when rendering an array of Scenes #2214

Closed
Stophface opened this issue Aug 10, 2017 · 7 comments
Closed

Unexpected behaviour when rendering an array of Scenes #2214

Stophface opened this issue Aug 10, 2017 · 7 comments

Comments

@Stophface
Copy link

Stophface commented Aug 10, 2017

Version

  • react-native-router-flux v4.0.0-beta.16
  • react-native v0.46.1

Expected behaviour

I expect the Scenes to be rendered.

Actual behaviour

Got the error Message

[react-native-router-flux] key should be defined for [object Object]

Steps to reproduce

That is my Code.
What I am having trouble with is rendering an array of Scenes. I need to do that if I don't want to hardcode every Scene and its corresponding Component, but rather feed it an object and then create the Scenes and the Routing. I have no idea how to render a list of Scenes...

_createList = () => {
    const list = this.state.structure.map((obj, index) => {
    return (
      <TouchableOpacity
        key = {obj.key}
        onPress = {() => this._onPress(obj, index)}
        <View style={{ flexDirection: "row", display: "flex" }}> 
            <Text 
              style = {this._createStyleText(index)}>   
              {obj.name}
            </Text>
        </View>
      </TouchableOpacity>
    )
    });
    return list;
   }

   _createScene = () => {
     const filterList = this._createList();
     const sceneList = filterList.map(obj => {
      return (
        <Scene 
          key = {obj.key}
          component = {obj}
          title = "Filter"/>
      )
     });
    return sceneList;
   }

  render() {
    return (
      <Router>
        <Scene key = "root">
          <View>
            {this._createScene()}
          </View>
        </Scene>
      </Router>
    )
  }
}
@aksonov
Copy link
Owner

aksonov commented Aug 10, 2017

Sorry, it is not supported behaviour.

@aksonov aksonov closed this as completed Aug 10, 2017
@Stophface
Copy link
Author

Stophface commented Aug 10, 2017

@aksonov so there is actually no way to render Scenes from a list of scenes? I have to hardcode every scene? There is absolutely no way?!

@aksonov
Copy link
Owner

aksonov commented Aug 10, 2017

Yes, it is how routing works. You don't render scenes within Router, but declare them.

@aksonov
Copy link
Owner

aksonov commented Aug 10, 2017

Probably you have to read more about navigation in general.

@Stophface
Copy link
Author

Stophface commented Aug 10, 2017

@aksonov Hm... How would you set up a navigation if you do not know how "deep" it goes, how many layers it has etc?

@aksonov
Copy link
Owner

aksonov commented Aug 10, 2017

Sorry, it is about your app architecture, not about RNRF.

@Stophface
Copy link
Author

@aksonov okay. thanks for your quick help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants