Skip to content

Instantly share code, notes, and snippets.

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
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,
},
})
import React from 'react'
import { NavigationContainer } from '@react-navigation/native'
import { createStackNavigator } from '@react-navigation/stack'
import SceneSplash from '../scenes/auth/sceneSplash'
import SceneAppLoading from '../scenes/auth/sceneAppLoading'
import SceneLogin from '../scenes/auth/sceneLogin'
import SceneHome from '../scenes/auth/sceneHome'
import SceneSettings from '../scenes/auth/sceneSettings'
import SceneGameHome from '../scenes/game/sceneGameHome'
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)
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()
import React from 'react'
import { NavigationContainer } from '@react-navigation/native'
import { createStackNavigator } from '@react-navigation/stack'
import SceneSplash from '../scenes/auth/sceneSplash'
const Stack = createStackNavigator()
const Navigation = () => (
<NavigationContainer>
<Stack.Navigator>
// 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) => ({
// our SpecialLink.jsx
const SpecialLink = (props) => {
const { url, label, ...additionalProps } = props
return (
<a href={url} ...additionalProps>
{label}
</a>
)
}
// our NewWorldComponent.jsx
const NewWorldComponent = (props) => {
const { targetWorld } = props
return (
<div>
Hello {targetWorld}!
</div>
)
}
// 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]