Mudanças entre as edições de "React Native"
Ir para navegação
Ir para pesquisar
| (7 revisões intermediárias pelo mesmo usuário não estão sendo mostradas) | |||
| Linha 34: | Linha 34: | ||
<Image> | <Image> | ||
<Image | <Image | ||
| − | source={{uri: "https://reactnative.dev/docs/assets/p_cat1.png"}} | + | source={ {uri: "https://reactnative.dev/docs/assets/p_cat1.png"} } |
| − | style={{width: 200, height: 200}} | + | style={ {width: 200, height: 200} } |
/> | /> | ||
<ScrollView> | <ScrollView> | ||
<TextInput> | <TextInput> | ||
| + | |||
==== Button ==== | ==== Button ==== | ||
<Button | <Button | ||
| Linha 45: | Linha 46: | ||
}} | }} | ||
disabled={!isHungry} | disabled={!isHungry} | ||
| + | color="#841584" | ||
title={isHungry ? "Pour me some milk, please!" : "Thank you!"} | title={isHungry ? "Pour me some milk, please!" : "Thank you!"} | ||
/> | /> | ||
| + | |||
==== Customizado ==== | ==== Customizado ==== | ||
const logo = { | const logo = { | ||
| Linha 53: | Linha 56: | ||
height: 64 | height: 64 | ||
}; | }; | ||
| + | |||
| + | |||
| + | === Plataform === | ||
| + | |||
| + | import { Plataform, Text } from 'react-native' | ||
| + | if (Platform.OS === 'android') { return <Text>ANDROID</text> } | ||
== Iniciar server == | == Iniciar server == | ||
| Linha 66: | Linha 75: | ||
import { StatusBar } from 'expo-status-bar'; | import { StatusBar } from 'expo-status-bar'; | ||
import React from 'react'; | import React from 'react'; | ||
| − | import Main from './ | + | import Main from './scr/Main.js'; |
import { StyleSheet, Text, View, Button } from 'react-native'; | import { StyleSheet, Text, View, Button } from 'react-native'; | ||
| − | + | /* FIM */ | |
export default Main | export default Main | ||
| Linha 80: | Linha 89: | ||
{ | { | ||
return ( | return ( | ||
| − | <View style={{flex:1}}></View> | + | <View style={css.fundo}> |
| − | + | <View style={ {flex:1} }></View> | |
| + | </View> | ||
| + | ) | ||
} | } | ||
export default Main | export default Main | ||
Edição atual tal como às 16h51min de 18 de julho de 2021
https://reactnative.dev/docs/getting-started
npm install --global expo-cli
Índice
Criar uma aplicação
expo init teste1 npm start npm run android npm run ios npm run web
Constates
const name = "NativeReact";
<Text>Hello, I am {name}!</Text>
Componentes
npm install @react-navigation/stack --save npm install @react-navigation/native --save
<View>
<Text>
<TextInput
style=Predefinição:Height: 40
placeholder="Type here to translate!"
onChangeText={text => setText(text)}
defaultValue={text}
/>
<Text style=Predefinição:Padding: 10, fontSize: 42>
{text.split(' ').map((word) => word && '🍕').join(' ')}
</Text>
Image
<Image>
<Image
source={ {uri: "https://reactnative.dev/docs/assets/p_cat1.png"} }
style={ {width: 200, height: 200} }
/>
<ScrollView>
<TextInput>
Button
<Button
onPress={() => {
setIsHungry(false);
}}
disabled={!isHungry}
color="#841584"
title={isHungry ? "Pour me some milk, please!" : "Thank you!"}
/>
Customizado
const logo = {
uri: 'https://reactnative.dev/img/tiny_logo.png',
width: 64,
height: 64
};
Plataform
import { Plataform, Text } from 'react-native'
if (Platform.OS === 'android') { return <Text>ANDROID</text> }
Iniciar server
Inicar o React para desenvolvimento e testes
expo start
ou
yarn start
Code Sample
APP
app.js
import { StatusBar } from 'expo-status-bar';
import React from 'react';
import Main from './scr/Main.js';
import { StyleSheet, Text, View, Button } from 'react-native';
/* FIM */
export default Main
scr/Main.js
import React from 'react'
import { Text, View, Button } from 'react-native'
/******************************************************/
import Book, { C1 } from './components/Books';
import css from './components/Styles';
export function Main()
{
return (
<View style={css.fundo}>
<View style={ {flex:1} }></View>
</View>
)
}
export default Main
Componentes
component/style.js
import { StyleSheet } from "react-native";
const style = StyleSheet.create(
{
fundo:
{
flexGrow: 1,
backgroundColor: 'red',
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#400000',
},
big:
{
fontSize: 48,
}
)
export default style
Bibliotecas
https://www.youtube.com/watch?v=71shcOjC_a4