Browse Source

Functional components

pull/1/head
Tim Glasgow 2 years ago
parent
commit
b54f379fec
  1. 42
      squarenotsquare/components/Game.js
  2. 42
      squarenotsquare/components/HighScore.js
  3. 42
      squarenotsquare/components/Home.js
  4. 42
      squarenotsquare/components/Settings.js
  5. 44
      squarenotsquare/components/Splash.js
  6. 82
      squarenotsquare/navigation/SquareStack.js

42
squarenotsquare/components/Game.js

@ -1,38 +1,14 @@
import React, { Component } from "react"; import React from "react";
import { Text, View } from "react-native"; import { Text, View } from "react-native";
import { connect } from "react-redux"; import { useState } from "react";
import { bindActionCreators } from "redux";
class Game extends Component { function Game(props){
constructor(props){
super(props)
this.state = {
} return (
<View>
//props.someNavAction, 5000 <Text style={{color: 'black'}}>test</Text>
//setTimeout(null, 5000); </View>
} );
render () {
return (
<View>
<Text>test</Text>
</View>
);
};
}
function mapStateToProps(){
}
const mapDispatchToProps = (dispatch) => {
let actions = {
//...someActionsGroup
};
return bindActionCreators(actions, dispatch);
} }
export default connect(mapStateToProps, mapDispatchToProps)(Game); export default Game;

42
squarenotsquare/components/HighScore.js

@ -1,38 +1,14 @@
import React, { Component } from "react"; import React from "react";
import { Text, View } from "react-native"; import { Text, View } from "react-native";
import { connect } from "react-redux"; import { useState } from "react";
import { bindActionCreators } from "redux";
class HighScore extends Component { function HighScore(props){
constructor(props){
super(props)
this.state = {
} return (
<View>
//props.someNavAction, 5000 <Text style={{color: 'black'}}>test</Text>
//setTimeout(null, 5000); </View>
} );
render () {
return (
<View>
<Text>test</Text>
</View>
);
};
}
function mapStateToProps(){
}
const mapDispatchToProps = (dispatch) => {
let actions = {
//...someActionsGroup
};
return bindActionCreators(actions, dispatch);
} }
export default connect(mapStateToProps, mapDispatchToProps)(HighScore); export default HighScore;

42
squarenotsquare/components/Home.js

@ -1,38 +1,14 @@
import React, { Component } from "react"; import React from "react";
import { Text, View } from "react-native"; import { Text, View } from "react-native";
import { connect } from "react-redux"; import { useState } from "react";
import { bindActionCreators } from "redux";
class Home extends Component { function Home(props){
constructor(props){
super(props)
this.state = {
} return (
<View>
//props.someNavAction, 5000 <Text style={{color: 'black'}}>test</Text>
//setTimeout(null, 5000); </View>
} );
render () {
return (
<View>
<Text>test</Text>
</View>
);
};
}
function mapStateToProps(){
}
const mapDispatchToProps = (dispatch) => {
let actions = {
//...someActionsGroup
};
return bindActionCreators(actions, dispatch);
} }
export default connect(mapStateToProps, mapDispatchToProps)(Home); export default Home;

42
squarenotsquare/components/Settings.js

@ -1,38 +1,14 @@
import React, { Component } from "react"; import React from "react";
import { Text, View } from "react-native"; import { Text, View } from "react-native";
import { connect } from "react-redux"; import { useState } from "react";
import { bindActionCreators } from "redux";
class Settings extends Component { function Settings(props){
constructor(props){
super(props)
this.state = {
} return (
<View>
//props.someNavAction, 5000 <Text style={{color: 'black'}}>test</Text>
//setTimeout(null, 5000); </View>
} );
render () {
return (
<View>
<Text>test</Text>
</View>
);
};
}
function mapStateToProps(){
}
const mapDispatchToProps = (dispatch) => {
let actions = {
//...someActionsGroup
};
return bindActionCreators(actions, dispatch);
} }
export default connect(mapStateToProps, mapDispatchToProps)(Settings); export default Settings;

44
squarenotsquare/components/Splash.js

@ -1,40 +1,14 @@
import React, { Component } from "react"; import React from "react";
import { Text, View } from "react-native"; import { Text, View } from "react-native";
import { connect } from "react-redux"; import { useState } from "react";
import { bindActionCreators } from "redux";
class Splash extends Component { function Splash(props){
constructor(props){
super(props)
this.state = {
} return (
<View>
//props.someNavAction, 5000 <Text style={{color: 'black'}}>test</Text>
//setTimeout(null, 5000); </View>
} );
render () {
return (
<View>
<Text>test</Text>
</View>
);
};
}
function mapStateToProps(){
return {
//system: state.system,
}
}
const mapDispatchToProps = (dispatch) => {
let actions = {
//...someActionsGroup
};
return bindActionCreators(actions, dispatch);
} }
export default connect(mapStateToProps, mapDispatchToProps)(Splash); export default Splash;

82
squarenotsquare/navigation/SquareStack.js

@ -1,4 +1,4 @@
import React, {Component} from 'react'; import React from 'react';
import {NavigationContainer} from '@react-navigation/native'; import {NavigationContainer} from '@react-navigation/native';
import {createStackNavigator} from '@react-navigation/stack'; import {createStackNavigator} from '@react-navigation/stack';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
@ -12,52 +12,40 @@ import Splash from '../components/Splash';
const SquareNav = createStackNavigator(); const SquareNav = createStackNavigator();
class SquareStack extends Component { function SquareStack() {
render() { let noHeader = {headerShown: false};
let noHeader = {headerShown: false};
return ( return (
<NavigationContainer ref={squareRef}> <NavigationContainer ref={squareRef}>
<SquareNav.Navigator initialRouteName="Splash"> <SquareNav.Navigator initialRouteName="Splash">
<SquareNav.Screen <SquareNav.Screen
name="Splash" name="Splash"
component={Splash} component={Splash}
options={noHeader} options={noHeader}
/> />
<SquareNav.Screen <SquareNav.Screen
name="Home" name="Home"
component={Home} component={Home}
options={noHeader} options={noHeader}
/> />
<SquareNav.Screen <SquareNav.Screen
name="HighScore" name="HighScore"
component={HighScore} component={HighScore}
options={noHeader} options={noHeader}
/> />
<SquareNav.Screen <SquareNav.Screen
name="Settings" name="Settings"
component={Settings} component={Settings}
options={noHeader} options={noHeader}
/> />
<SquareNav.Screen <SquareNav.Screen
name="Game" name="Game"
component={Game} component={Game}
options={noHeader} options={noHeader}
/> />
</SquareNav.Navigator> </SquareNav.Navigator>
</NavigationContainer> </NavigationContainer>
) )
}
} }
function mapStateToProps(state) { export default SquareStack;
return {
Navigation: state.Navigation
}
}
function mapDispatchToProps(dispatch) {
return {dispatch: dispatch};
}
export default connect(mapStateToProps, mapDispatchToProps)(SquareStack)
Loading…
Cancel
Save