concept render method in category react native

This is an excerpt from Manning's book React Native in Action.
render() { return ( <View> <Text>Hello from Home</Text> </View>) }The code for the component is executed in the
render
method, and the content after thereturn
statement returns what’s rendered on the screen. When therender
method is called, it should return a single child element. Any variables or functions declared outside of therender
function can be executed here. If you need to do any calculations, declare any variables using state or props, or run any functions that don’t manipulate the state of the component, you can do so between therender
method and thereturn
statement.
2.3.1 Using the render method to create a UI
The
render
method is the only method in the component specification that’s required when creating a component. It must return either a single child element,null
, orfalse
. This child element can be a component you declared (such as aView
orText
component), or another component you defined (maybe aButton
component you created and imported into the file):render() { return ( <View> <Text>Hello</Text> </View> ) }You can use the
render
method with or without parentheses. If you don’t use parentheses, then the returned element must of course be on the same line as thereturn
statement:render() { return <View><Text>Hello</Text></View> }The
render
method can also return another component that was defined elsewhere:render() { return <SomeComponent /> } #or render() { return ( <SomeComponent /> ) }