React Native Flashcards
What do we need to create to get content on the screen?
We need to create a component, wich is a JavaScript Function and then Render it to the UI (user interface)
What’s a component?
Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called “props”) and return React elements describing what should appear on the screen.
What are the 2 types of components?
Functional and Class Components
What’s the only thing that is required when creating a component?
The only thing that’s required is a Render function which returns some JSX to render.
What can you do with components?
Components let you split the UI into independent, reusable pieces, and think about each piece in isolation.
What is React?
React is a declarative, efficient, and flexible JavaScript library for building user interfaces(UI’s).
What is React Native?
React Native is like React, but it uses native components instead of web components as building blocks. Its the mobile or App kind of version.
‘React’ Library points
- Knows how a component should behave
- Knows how to take a bunch of components and make them work together,
- It’s kind of the brain.
‘React Native’ Library points
- Can be thought of as our portal to the mobile device
- Knows how to take the output from a component and place it on the screen
- Provides default core components (image, text, etc).
The import statement
it is used to import functions, objects, libraries or primitives which are defined in and exported by an external module, script, or the like.
How do you define a component?
To define a component you need to write a JavaScript function, This function must ‘return’ some object that describes what it should look on our device.
Create a symple component (write the code)
const App = () => { render () { } };
What is JSX?
JSX is an extension to the JavaScript language that is used to write React components, its syntaxis sugar to make our code more legible.
What is JSX definition?
JSX is a preprocessor step that adds XML syntax to JavaScript.
What’s a component? ‘My definition’
A component is a JavaScript function that returns some amount of JSX.
React Native is going to take our component and decide based on the information what is going to get rendered to the screen.
What is AppRegistry?
AppRegistry is the JS entry point to running all React Native apps.
How should root component be registered?
App root components should register themselves with AppRegistry.registerComponent, then the native system can load the bundle for the app and then actually run the app when it’s ready by invoking AppRegistry.runApplication.
Whta’s AppRegistry for?
In any ReactNative application that we create we need to at least register one component to the application, so it knows that its about to render an aplication called “SomeApp” (The name of the string must match the name of the app).
Second we pass a function that returns the first component(function) to render for our application.
Write an AppRegistry
ReactNative.AppRegistry.registerComponent(‘appName’), () => Component);
or deconstructed:
import { AppRegistry, View } from ‘react-native’;
AppRegistry.registerComponent(‘appName’), () => Component);
Are there global variables on React Native?
No, everything is an independent component.