React Native Flashcards

1
Q

What do we need to create to get content on the screen?

A

We need to create a component, wich is a JavaScript Function and then Render it to the UI (user interface)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What’s a component?

A

Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called “props”) and return React elements describing what should appear on the screen.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the 2 types of components?

A

Functional and Class Components

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What’s the only thing that is required when creating a component?

A

The only thing that’s required is a Render function which returns some JSX to render.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What can you do with components?

A

Components let you split the UI into independent, reusable pieces, and think about each piece in isolation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is React?

A

React is a declarative, efficient, and flexible JavaScript library for building user interfaces(UI’s).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is React Native?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

‘React’ Library points

A
  • 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

‘React Native’ Library points

A
  • 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).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

The import statement

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you define a component?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Create a symple component (write the code)

A
const App = () => {
  render () {
  }
};
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is JSX?

A

JSX is an extension to the JavaScript language that is used to write React components, its syntaxis sugar to make our code more legible.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is JSX definition?

A

JSX is a preprocessor step that adds XML syntax to JavaScript.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What’s a component? ‘My definition’

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is AppRegistry?

A

AppRegistry is the JS entry point to running all React Native apps.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

How should root component be registered?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Whta’s AppRegistry for?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Write an AppRegistry

A

ReactNative.AppRegistry.registerComponent(‘appName’), () => Component);

or deconstructed:

import { AppRegistry, View } from ‘react-native’;

AppRegistry.registerComponent(‘appName’), () => Component);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Are there global variables on React Native?

A

No, everything is an independent component.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Import Destructuring, what it is?

A

When we import the React Native Library, we don’t want to import the whole library, so instead we import only the properties that we want.

22
Q

Give an example of importing a Text property from React Native.

A

import { Text } from ‘react-native’;

23
Q

How many component should we create per file?

A

In React Native we create only one component per file.

24
Q

How to name a component.

A

As a rule of thumb we always name the function component with the same name as the file in wich is created, to make it more readable.

25
Q

What’s a root component?

A

Root components are the firsts components to be rendered to the screen. Usually the App component.

26
Q

What’s a child component?

A

The child components are all the components that we nest inside our Root component.

27
Q

What’s the ‘export’ method used for?

A

The ‘export’ method is used to make components or other js files available to other files in the same project. it works exactly as the import method.
ex: export default Header;

28
Q

How do we import components to our files?

A

import NameOfFile from ‘./Path/to/our/component’;

29
Q

Where do we put our styling on React Native?

A

We put the styling inside of our component file.

30
Q

How do you style a component?

A

We have to create a new component usually called ‘styles’ inside of our component file that we want to style.

31
Q

What’s Flexbox?

A

Flexbox is an algorithm used to specify the layout of its children (It’s a system to positioning elements within a container).
Flexbox is designed to provide a consistent layout on different screen sizes.

32
Q

What properties do we use with flexbox to center an element in our container?

A

justifyContent: ‘center’; and alignItems: ‘center’;

33
Q

For what do we use props or properties?

A

Whenever we want to pass some information from our root component to our child component we use properties.

34
Q

How do we pass properties?

A
  1. Identify the value or variable that we want to be provided by the parent. ex: const Header = (props) => {
  2. We provide a reference to the props that’s coming from the parent component. ex: {props.headerText}
  3. We’ll make sure that the parent component provides that specific prop. ex: we pass the properti of headerText and the string ‘Albums’
35
Q

What do we use to make reference to a javascript variable in React?

A

we use curly braces {props}

36
Q

Why do we make components reusable?

A

It save us a lot of time by having to make less files for the same kind of component.

37
Q

There are three main patterns to customize components.

A
  1. Pass data via props
  2. Nest component
  3. Higher order component
38
Q

Return two components at the same time.

A

In React Native when we want to return two or more compnents of JSX at the same time we need to nest or wrap them in a single tag, we can’t return two siblings at one time.

39
Q

Functional Components

A

Functional components as the name says it, it’s a JavaScript function that returns some amount of JSX.
Data inn –> Functional Component –> out JSX
- Used for presenting static data
- Can’t handle fetching data
- Easy to write

40
Q

Functional Component Example:

A
const Header = () => {
  return Hi there!
};
41
Q

Class Components

A

They have more functionality built to them, more capability. they can be used for:

  • Used for dynamic sources of data
  • Fetching data
  • User events
  • Easier to write large components
  • Easier to organize large amounts of code
  • Class type structure
  • Knows when it get rendered to the device (useful for data fetching)
  • More code to write
42
Q

Class Component Example:

A
class Header extends Component {
  render () {
    return Hi there!
  }
};
43
Q

extends Component

A
Whe use extend Component to let React Native that our function is a component class type and we want to use its properties.
We also have to import it from the react library in our import statement as so: import React, { Component } from 'react';
44
Q

Trivia

A

Class based components do not requite semicolon ; but they do require a render method.

45
Q

Lifecycle methods:

A

Life cycle methods are like functions that will be placed on our class component that will be automatically called at some or diferent point on our program, depending on wich method we use

46
Q

componentWillMount():

A

componentWillMount() is invoked immediately before mounting occurs. It is called before render(), therefore setting state synchronously in this method will not trigger a re-rendering. Avoid introducing any side-effects or subscriptions in this method.

47
Q

Axios

A

It’s a Library that can be installed using npm that is used to make HTTP requests.

48
Q

Axios HTTP request code example:

A

axios.get(‘https://url’)

.then(response => this.setState({ albums: response.data }));

49
Q

Synchronous vs Asynchronous operations.

A

A synchronous operation blocks a process till the operation completes. An asynchronous operation is non-blocking and only initiates the operation.

50
Q

State

A

There are two types of data that control a component: props and state. props are set by the parent and they are fixed throughout the lifetime of a component. For data that is going to change, we have to use state.

In general, you should initialize state in the constructor, and then call setState when you want to change it.

51
Q

How do we set an initial state (code)?

A

state = {};

this is an empty initial state, we can change it later on with: this.setState