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.

Is it possible to "curry" <Scene>, <Drawer>, <Tabs>, maybe others?

See original GitHub issue

Versions

  • react-native-router-flux v4.0.0-beta.28
  • react-native v0.51.0

Expected behaviour

I’m making some wrappers for the built-in <Scene /> component, changing it to take children instead of component, changing the api from <Scene component={...} /> to <MyScene>{component}</MyScene>

so I can get a router file that looks like the following:

const MyComponent = () => (
  <View>
    <Text>Hello, World!</Text>
  </View>
)
const MyScene = ({ children }) => <Scene key={'myScene'} component={children} />
const MyStack = ({ children }) => <Stack key={'myStack'}>{children}</Stack>
const MyTabs = ({ children }) => <Tabs key={'myTabs'} hideNavBar>{children}</Tabs>
const MyDrawer = ({ children }) => <Drawer key={'myDrawer'} hideNavBar>{children}</Drawer>

export type Props = {}
export default class App extends Component<Props> {
  render () {
    return (
      <Router>
        <MyStack>
          <MyDrawer>
            <MyTabs>
              <MyScene>
                <MyComponent />
              </MyScene>
            </MyTabs>
          </MyDrawer>
        </MyStack>
      </Router>
    )
  }
}

Actual behaviour

When wrapping <Scene>

Error: Route 'key1' should declare a screen. For example:

import MyScreen from './MyScreen';
...
key1: {
  screen: MyScreen,
}

This error is located at:
    in Router (at App.js:36)
    in App (at renderApplication.js:33)
    in RCTView (at View.js:60)
    in View (at AppContainer.js:102)
    in RCTView (at View.js:60)
    in View (at AppContainer.js:122)
    in AppContainer (at renderApplication.js:32)

When wrapping the other components, they compile but the router doesn’t see any of the props

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6

github_iconTop GitHub Comments

3reactions
Blapicommented, Jun 12, 2018

Just… why? I don’t think it is a good practice at all, and the library is already good enough to do whatever you want, what you’re doing is not very appropriated to the library and kind of useless. I strongly advise you to check the example project and understand the library

2reactions
wolverinekscommented, Jun 12, 2018

i prefer passing components as children whenever possible

Read more comments on GitHub >

github_iconTop Results From Across the Web

Curry Rub Recipe | Martha Stewart
Ingredients · 4 teaspoons curry powder · 1 1/2 teaspoons ground coriander · 1 1/2 teaspoons coarse salt · 1 teaspoon ground ginger...
Read more >
Curry Chicken with Cilantro Lime Sauce - Martha Stewart
Step 1. Sprinkle chicken with curry powder, season with salt and pepper. · Step 2. In a blender, combine 1 tablespoon oil, cilantro,...
Read more >
Chicken Curry Recipe | Martha Stewart
In a 5-quart slow cooker, toss chicken, onion, garlic, ginger, curry powder, coriander, and cumin to coat. Season with 2 teaspoons salt.
Read more >
Algorithms and their others: Algorithmic culture in context
In doing so, I hope to be able to identify fruitful directions for taking up the algorithm as an object of attention within...
Read more >
DOCUMENT RESUME AUTHOR Highlights of American ...
The scene ends in thanksgiving by the good people who have been able to triumph over the bad. The struggle and victory are...
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