Продолжаем курс по Redux или клонируем репу:
git clone https://github.com/react-native-village/react-native-init.git
Окончательный код проекта дуступен здесь
Переходим в папку проекта
cd react-native-init/stargate2
Удалям редакс из проекта
import React, { useState, useEffect } from 'react' | |
import { View, Text } from 'react-native' | |
const Timer = () => { | |
const [date, setDate] = useState(60) | |
const tick = () => setDate(date - 1) | |
useEffect(() => { | |
const timerID = setInterval(() => tick(), 1000) |
export const Device = { | |
select(variants) { | |
if (W >= 300 && W <= 314) return variants.mobile300 || {} | |
if (W >= 315 && W <= 341) return variants.iphone5 || {} | |
if (W >= 342 && W <= 359) return variants.mobile342 || {} | |
if (W >= 360 && W <= 374) return variants.mi5 || {} | |
if (W >= 375 && W <= 399) return variants.iphone678 || {} | |
if (W >= 400 && W <= 409) return variants.mobile400 || {} | |
if (W >= 410 && W <= 414) return variants.googlePixel || {} | |
if (W >= 415 && W <= 434) return variants.mobile415 || {} |
const App = () => { | |
const { container } = styles | |
const [currentIndex, setCurrentIndex] = useState(0) | |
const array = [{ title: "Today" }, { title: "Week" }, { title: "Month" }] | |
return ( | |
<View style={container}> | |
<Text>{${currentIndex}}</Text> | |
{array.map(({ title }, i) => ( | |
<TouchableOpacity key={title} onPress={() => setCurrentIndex(i)}> |
this.setState(prevState => ({ check: !prevState.check})) |
import React, { Component } from 'react' | |
import { View, StyleSheet } from 'react-native' | |
import ButtonTransactionItem from './ButtonTransactionItem' | |
const styles = StyleSheet.create({ | |
container: { | |
flexDirection: 'row', | |
backgroundColor: 'white', | |
height: 50 | |
} |
import { useApolloClient } from 'react-apollo-hooks' | |
const App = () => { | |
const client = useApolloClient() | |
const onPress = elem => () => client.writeData({ data: { elem } }) | |
return ( | |
<View> | |
<TouchableOpacity onPress={onPress('text')}> | |
<Text>Set</Text> |
Продолжаем курс по Redux или клонируем репу:
git clone https://github.com/react-native-village/react-native-init.git
Окончательный код проекта дуступен здесь
Переходим в папку проекта
cd react-native-init/stargate2
Удалям редакс из проекта
export default { | |
test: 'Hello', | |
history: [ | |
{ | |
id: 0, | |
up: false, | |
}, | |
{ | |
id: 1, | |
up: false, |
import React from 'react' | |
import { Provider } from 'react-redux' | |
import { composeWithDevTools } from 'redux-devtools-extension' | |
import { createStore, applyMiddleware } from 'redux' | |
import ReduxThunk from 'redux-thunk' | |
import reducers from './src/reducers' | |
import AppNavigator from './src/AppNavigator' | |
const store = createStore(reducers, composeWithDevTools(applyMiddleware(ReduxThunk))) |