4

I have written a simple application using react native for android. i want to know how do i use more than one component adjacent to each other in the return function. If I put a toolbar tag, it gives an error.

return (
<MovieScreen
      style={{flex: 1}}
      navigator={navigationOperations}
      movie={route.movie}
/>
);

Above works. Below one gives error

return (
<Toolbar/>
<MovieScreen
      style={{flex: 1}}
      navigator={navigationOperations}
      movie={route.movie}
/>
);

Please help.

2 Answers 2

4

Enclose it in a View tag if you think that's how you want to showcase it.

return (
  <View style={{flex: 1}}>
    <Toolbar />
    <MovieScreen
      style={{flex: 1}}
      navigator={navigationOperations}
      movie={route.movie}
    />
  </View>
);

This should work.

Sign up to request clarification or add additional context in comments.

Comments

3

You cannot return 2 values remember? You can only return one encapsulated tag. So, wrap a view. It will work :)

return (
  <View style={{flex: 1}}>
    <Toolbar />
    <MovieScreen
      style={{flex: 1}}
      navigator={navigationOperations}
      movie={route.movie}
    />
  </View>
);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.