Skip to content

Commit

Permalink
Make screens as React classes to make hot reload work (#2224)
Browse files Browse the repository at this point in the history
  • Loading branch information
aksonov committed Aug 14, 2017
1 parent 35efe6e commit 701d940
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 30 deletions.
20 changes: 10 additions & 10 deletions Example/components/Register.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ const styles = StyleSheet.create({
},
});

const Register = () => (
<View style={styles.container}>
<Text>Register page</Text>
<Button onPress={()=>Actions.register2()}>Register2</Button>
<Button onPress={Actions.home}>Replace screen</Button>
<Button onPress={Actions.pop}>Back</Button>
</View>
);

export default Register;
export default class Register extends React.Component {
render() {
return <View style={styles.container}>
<Text>Register page</Text>
<Button onPress={()=>Actions.register2()}>Register</Button>
<Button onPress={Actions.home}>Replace screen</Button>
<Button onPress={Actions.pop}>Back</Button>
</View>
}
}
41 changes: 21 additions & 20 deletions Example/components/TabView.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,29 @@ const styles = StyleSheet.create({
},
});

const TabView = (props) => {
return (
<View style={[styles.container, props.sceneStyle ]}>
<Text>Tab title:{props.title} name:{props.name}</Text>
<Text>Tab data:{props.data}</Text>
{props.name === 'tab1_1' &&
class TabView extends React.Component {
render() {
return (
<View style={[styles.container, this.props.sceneStyle ]}>
<Text>Tab title:{this.props.title} name:{this.props.name}</Text>
<Text>Tab data:{this.props.data}</Text>
{this.props.name === 'tab1_1' &&
<Button onPress={()=>Actions.tab1_2()}>next screen for tab1_1</Button>
}
{props.name === 'tab2_1' &&
}
{this.props.name === 'tab2_1' &&
<Button onPress={()=>Actions.tab2_2()}>next screen for tab2_1</Button>
}
<Button onPress={Actions.pop}>Back</Button>
<Button onPress={() => { Actions.tab1(); }}>Switch to tab1</Button>
<Button onPress={() => { Actions.tab2(); }}>Switch to tab2</Button>
<Button onPress={() => { Actions.tab3(); }}>Switch to tab3</Button>
<Button onPress={() => { Actions.tab4(); }}>Switch to tab4</Button>
<Button onPress={() => { Actions.tab5({ data: 'test!' }); }}>Switch to tab5 with data</Button>
<Button onPress={() => { Actions.echo(); }}>push clone scene (EchoView)</Button>
</View>
);
};

}
<Button onPress={Actions.pop}>Back</Button>
<Button onPress={() => { Actions.tab1(); }}>Switch to tab1</Button>
<Button onPress={() => { Actions.tab2(); }}>Switch to tab2</Button>
<Button onPress={() => { Actions.tab3(); }}>Switch to tab3</Button>
<Button onPress={() => { Actions.tab4(); }}>Switch to tab4</Button>
<Button onPress={() => { Actions.tab5({ data: 'test!' }); }}>Switch to tab5 with data</Button>
<Button onPress={() => { Actions.echo(); }}>push clone scene (EchoView)</Button>
</View>
);
}
}
TabView.contextTypes = contextTypes;
TabView.propTypes = propTypes;

Expand Down

0 comments on commit 701d940

Please sign in to comment.