Instructor: Import style sheet from React native. Then we can make a new style sheet and extract these inline styles in order to clean up the components in our render method.
Make a new style sheet by defining a const called styles and calling the create method on style sheet. The create method takes an object. This object should have keys like header, which have the name styles that you're creating, and all the values are objects.
Inside of those objects, we can define our styles. The header style will contain all of the styles we define for the header. We can use that header style as the style for the header text by specifying styles.header as the style prop for a text component.
Writing React native style sheets, we'll feel very much like writing CSS for React with the other big difference being that all the style keys are camel keys. Let's continue cleaning up the styles by extracting styles for the row, the edges, the name and address, and the address text itself, and reloading.
Again, nothing is changed. We know that we transfer the styles correctly to the style sheet. The style prop can also be an array of style objects. You can also make style sheet styles and inline styles.
For a row, we could supply an array of styles to the style prop. The first element in the array would be the row style from style sheet. Then, we could overwrite the background color of the row based on its index, if we wanted to do alternating straight pattern to our list. Without background, we should properly add a bit of padding to separate the content from the edges of the row.
Finally, styles can be defined in another file and even shared among components. To extract this header style for example, we could cut out that style and make a new file which we'll call headerstyle.js. In header style, we can just import style sheet from React native, and export default a new style sheet, and paste in our header style.
Back in app JS, we can import that new style sheet and use it to style our header. When we reload, the header looks the same, but it's now pulling from the new header style, instead of being defined directly in app.js.