This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { USER_LOGIN, USER_LOGOUT } from '../actions/user.actions' | |
const initialState = { | |
isLoggedIn: false, | |
} | |
const userReducer = (state = initialState, action) => { | |
switch (action.type) { | |
case USER_LOGIN: { | |
const { name } = action.payload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const USER = '[USER]' | |
export const USER_LOGIN = `${USER} Set user as logged in` | |
export const USER_LOGOUT = `${USER} Set user as logged out` | |
export const userLogin = ({ name }) => ({ | |
type: USER_LOGIN, | |
payload: { | |
name, | |
}, | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect } from 'react' | |
import { Text } from 'react-native' | |
import PropTypes from 'prop-types' | |
import DefaultPage from '../../components/DefaultPage' | |
const SceneSplash = ({ navigation }) => { | |
useEffect(() => { | |
setTimeout(() => { | |
navigation.navigate('Login') | |
}, 2000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { Provider } from 'react-redux' | |
import { enableScreens } from 'react-native-screens'; | |
import configureStore from './src/redux/store' | |
import { initialiseApplication } from './src/redux/actions/application.actions' | |
import Navigation from './src/navigation' | |
enableScreens(); | |
const store = configureStore() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/components/other/VersionTag.jsx | |
import React from 'react' | |
import { Text } from 'react-native' | |
import { connect } from 'react-redux' | |
const VersionTag = ({ applicationState: { version, name } }) => ( | |
<Text>{`${name} (v${version})`}</Text> | |
) | |
const mapStateToProps = (state) => ({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// our SpecialLink.jsx | |
const SpecialLink = (props) => { | |
const { url, label, ...additionalProps } = props | |
return ( | |
<a href={url} ...additionalProps> | |
{label} | |
</a> | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// our NewWorldComponent.jsx | |
const NewWorldComponent = (props) => { | |
const { targetWorld } = props | |
return ( | |
<div> | |
Hello {targetWorld}! | |
</div> | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// let's add out dice in a game | |
const dicePool = [5, 2, 4] | |
const firstDiceThrow = [1, 4, 6] | |
const secondDiceThrow = [3, 6, 1] | |
console.log(dicePool) // [5, 2, 4] | |
dicePool.push(...firstDiceThrow, ...secondDiceThrow) | |
console.log(dicePool) // [5, 2, 4, 1, 4, 6, 3, 6, 1] |