Working With Content
Overview of React Component
Every React component tends to have the following parts:
Import of libraries required to create the component
The component itself–a function that returns some JSX
A stylesheet to style the component
Export of the component, so it can be used elsewhere
Things to note:
Text
is an example of a primitive React element. Others includeView
,Image
, andButton
.You don't have to pass your
styles
object throughStyleSheet.create
. You could directly pass inline styling to each of your components.StyleSheet.create
is only used because it gives helpful error messages when things go wrong.
Showing a Custom Component
To display a custom component, we just need to make sure it's included in one of the routes that React Native creates.
Now when you visit the app, it will be the first thing you see!
Note: The react-navigation
library tools just help us handle navigation and control the screens available to the user.
Last updated