-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Created new React Native Components entry #1269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
ace6d21
d7c1b5e
0b18ab3
423864d
7698965
7701566
5325386
79a1e8d
a029174
db11768
810e9ad
4482a93
1c60c07
6836e33
1264bb6
0f6a793
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,159 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Title: 'React Native Components' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description: 'Bundles of reusable, nestable code used to describe the appearance and behavior of a UI.' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ericsonrd marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Subjects: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - 'Mobile Development' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Tags: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - 'Components' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - 'React Native' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - 'UI' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CatalogContent: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - 'learn-react-native' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - 'paths/front-end-engineer-career-path' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| **React Native Components** are bundles of reusable, nestable code used to describe the appearance and behavior of a User Interface (UI). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ericsonrd marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## UI Views | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| The basic building block of a UI is the View, a small, rectangular and often times nestable element that can be used to display text, images and respond to user input. React Native works by invoking these Views in their native environment with JavaScript, using React Components. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ericsonrd marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## Native Components | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| These previously mentioned platform-backed components are called Native Components, and React Native creates the corresponding, platform specific Views (whether iOS or Android) for these components at runtime. Because of this, React Native apps look, feel and perform like Native apps. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ericsonrd marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## Core Components | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| React Native offers a set of essential, ready-to-use Native Components called Core Components. There are many components ranging from Text to Activity Indicators. Most apps will use these Core Components: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | React Native Component | Description | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | React Native Component | Description | | |
| | Native Component | Description | |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| | \<View> | Is a container analog to a \<div> in html. It supports layout with flexbox, styles, touch handling, accessibility controls and can contain other components inside, including other views. | | |
| | \<Text> | Displays text, support styles and touch events. It can also nest other Text components. | | |
| | \<Image> | Displays different types of images, including from network, static, local disks and from ‘data:’ uri scheme. | | |
| | \<TextInput> | Allows the input of text by the user and provides several configuration capabilities such as auto-correction, auto-capitalization, placeholder text, etc. | | |
| |\<ScrollView> | An scrolling container that can nest multiple components and views. It can scroll vertically or horizontally. | | |
| | `<View>` | A common container component that supports layout with flexbox, styles, touch handling, accessibility controls, and can contain other components inside such as other views. It is analogous to a non-scrolling [`<div>`](https://www.codecademy.com/resources/docs/html/elements/div) HTML element. | | |
| | `<Text>` | Displays text and supports styles and touch events. It is analogous to a [paragraph element](https://www.codecademy.com/resources/docs/html/paragraphs). | | |
| | `<Image>` | Displays different types of images, including from network, static, local disks, and from ‘data:’ [URI](https://www.codecademy.com/resources/docs/general/uri) scheme. It is analogous to an [image element](https://www.codecademy.com/resources/docs/html/images). | | |
| | `<TextInput>` | Allows the input of text by the user and provides several configuration capabilities such as auto-correction, auto-capitalization, placeholder text, etc. It is analogous to an [`<input>`] element with its `type` attribute set to `"text"`. | | |
| | `<ScrollView>` | A container that can nest multiple components and views that can scroll vertically or horizontally. It is analogous to a scrolling `div` element. | |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| React Native Components can also be custom-built, and there’s a big ecosystem of these Community-built Components that can be accessed on the [Native Directory](https://reactnative.directory/) | |
| Components can also be custom-built, and there’s a big ecosystem of these community-built components that can be accessed on the [Native Directory](https://reactnative.directory/). |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ## React Native Components are based on React | |
|  | |
|  |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| React Native Components share the same API structure as React Components. Whatever a component returns is rendered as a React element, which allows to describe what’s seen on the screen. They can also be defined as Function Component or Class Components: | |
| ### Examples | |
| React Natives uses the same component syntax structure for its views to display elements to the screen, like in React.js. The following examples are of a `Box` component defined as both a class and functional component: |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| import React from 'react'; | |
| import { Text } from 'react-native'; | |
| const Box= () => { | |
| return ( | |
| <Text>I have a small box</Text> | |
| ); | |
| } | |
| export default Box; | |
| import React, { Component } from 'react'; | |
| import { Text } from 'react-native'; | |
| // Functional Component | |
| const Box = () => { | |
| return ( | |
| <Text>I have a small box</Text> | |
| ); | |
| } | |
| // Class Component | |
| class Box extends Component { | |
| render() { | |
| return ( | |
| <Text>I have a small box</Text> | |
| ); | |
| } | |
| } | |
| export default Box; |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| React Native Components also use JSX, accept Props and manage State. | |
| Views also use [JSX](https://www.codecademy.com/resources/docs/react/jsx), accept [props](https://www.codecademy.com/resources/docs/react/props), and manage [state](https://www.codecademy.com/resources/docs/react/state). |
Uh oh!
There was an error while loading. Please reload this page.