mirror of
https://github.com/laurent22/joplin.git
synced 2024-11-27 08:21:03 +02:00
Moved root to separate file
This commit is contained in:
parent
7d7ee268f0
commit
c75d34f664
@ -15,6 +15,12 @@ import { Log } from 'src/log.js'
|
||||
|
||||
import { LoginButton } from 'src/components/login-button.js';
|
||||
|
||||
import { Root } from 'src/root.js';
|
||||
|
||||
|
||||
//AppRegistry.registerComponent('AwesomeProject', () => AppNavigator);
|
||||
AppRegistry.registerComponent('AwesomeProject', () => Root);
|
||||
|
||||
|
||||
// let debugMode = true;
|
||||
// let clientId = 'A7D301DA7D301DA7D301DA7D301DA7D3';
|
||||
@ -117,88 +123,88 @@ import { LoginButton } from 'src/components/login-button.js';
|
||||
|
||||
|
||||
|
||||
import { StackNavigator } from 'react-navigation';
|
||||
import { addNavigationHelpers } from 'react-navigation';
|
||||
// import { StackNavigator } from 'react-navigation';
|
||||
// import { addNavigationHelpers } from 'react-navigation';
|
||||
|
||||
class MainScreen extends React.Component {
|
||||
static navigationOptions = {
|
||||
title: 'Welcome',
|
||||
};
|
||||
render() {
|
||||
const { navigate } = this.props.navigation;
|
||||
return (
|
||||
<Button
|
||||
title="Go to Jane's profile"
|
||||
onPress={() =>
|
||||
navigate('Profile', { name: 'Jane' })
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
// class MainScreen extends React.Component {
|
||||
// static navigationOptions = {
|
||||
// title: 'Welcome',
|
||||
// };
|
||||
// render() {
|
||||
// const { navigate } = this.props.navigation;
|
||||
// return (
|
||||
// <Button
|
||||
// title="Go to Jane's profile"
|
||||
// onPress={() =>
|
||||
// navigate('Profile', { name: 'Jane' })
|
||||
// }
|
||||
// />
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
class ProfileScreen extends React.Component {
|
||||
static navigationOptions = {
|
||||
title: 'Profile',
|
||||
};
|
||||
render() {
|
||||
const { navigate } = this.props.navigation;
|
||||
return (
|
||||
<Button
|
||||
title="Go to main"
|
||||
onPress={() =>
|
||||
navigate('Main')
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
// class ProfileScreen extends React.Component {
|
||||
// static navigationOptions = {
|
||||
// title: 'Profile',
|
||||
// };
|
||||
// render() {
|
||||
// const { navigate } = this.props.navigation;
|
||||
// return (
|
||||
// <Button
|
||||
// title="Go to main"
|
||||
// onPress={() =>
|
||||
// navigate('Main')
|
||||
// }
|
||||
// />
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
const AppNavigator = StackNavigator({
|
||||
Main: {screen: MainScreen},
|
||||
Profile: {screen: ProfileScreen},
|
||||
});
|
||||
// const AppNavigator = StackNavigator({
|
||||
// Main: {screen: MainScreen},
|
||||
// Profile: {screen: ProfileScreen},
|
||||
// });
|
||||
|
||||
class AppComponent extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<AppNavigator navigation={addNavigationHelpers({
|
||||
dispatch: this.props.dispatch,
|
||||
state: this.props.nav,
|
||||
})} />
|
||||
);
|
||||
}
|
||||
}
|
||||
// class AppComponent extends React.Component {
|
||||
// render() {
|
||||
// return (
|
||||
// <AppNavigator navigation={addNavigationHelpers({
|
||||
// dispatch: this.props.dispatch,
|
||||
// state: this.props.nav,
|
||||
// })} />
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
const navInitialState = AppNavigator.router.getStateForAction(AppNavigator.router.getActionForPathAndParams('Main'));
|
||||
// const navInitialState = AppNavigator.router.getStateForAction(AppNavigator.router.getActionForPathAndParams('Main'));
|
||||
|
||||
const navReducer = (state = navInitialState, action) => {
|
||||
const nextState = AppNavigator.router.getStateForAction(action, state);
|
||||
return nextState || state;
|
||||
};
|
||||
// const navReducer = (state = navInitialState, action) => {
|
||||
// const nextState = AppNavigator.router.getStateForAction(action, state);
|
||||
// return nextState || state;
|
||||
// };
|
||||
|
||||
const appReducer = combineReducers({
|
||||
nav: navReducer,
|
||||
});
|
||||
// const appReducer = combineReducers({
|
||||
// nav: navReducer,
|
||||
// });
|
||||
|
||||
const mapStateToProps = (state) => ({
|
||||
nav: state.nav
|
||||
});
|
||||
// const mapStateToProps = (state) => ({
|
||||
// nav: state.nav
|
||||
// });
|
||||
|
||||
const App = connect(mapStateToProps)(AppComponent);
|
||||
// const App = connect(mapStateToProps)(AppComponent);
|
||||
|
||||
const store = createStore(appReducer);
|
||||
// const store = createStore(appReducer);
|
||||
|
||||
class Root extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<Provider store={store}>
|
||||
<App />
|
||||
</Provider>
|
||||
);
|
||||
}
|
||||
}
|
||||
// class Root extends React.Component {
|
||||
// render() {
|
||||
// return (
|
||||
// <Provider store={store}>
|
||||
// <App />
|
||||
// </Provider>
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
//AppRegistry.registerComponent('AwesomeProject', () => AppNavigator);
|
||||
AppRegistry.registerComponent('AwesomeProject', () => Root);
|
||||
// //AppRegistry.registerComponent('AwesomeProject', () => AppNavigator);
|
||||
// AppRegistry.registerComponent('AwesomeProject', () => Root);
|
91
ReactNativeClient/src/root.js
Normal file
91
ReactNativeClient/src/root.js
Normal file
@ -0,0 +1,91 @@
|
||||
import React, { Component } from 'react';
|
||||
import { Button } from 'react-native';
|
||||
import { connect } from 'react-redux'
|
||||
import { Provider } from 'react-redux'
|
||||
import { createStore } from 'redux';
|
||||
import { combineReducers } from 'redux';
|
||||
import { Log } from 'src/log.js'
|
||||
import { StackNavigator } from 'react-navigation';
|
||||
import { addNavigationHelpers } from 'react-navigation';
|
||||
|
||||
class MainScreen extends React.Component {
|
||||
static navigationOptions = {
|
||||
title: 'Welcome',
|
||||
};
|
||||
render() {
|
||||
const { navigate } = this.props.navigation;
|
||||
return (
|
||||
<Button
|
||||
title="Go to Jane's profile"
|
||||
onPress={() =>
|
||||
navigate('Profile', { name: 'Jane' })
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class ProfileScreen extends React.Component {
|
||||
static navigationOptions = {
|
||||
title: 'Profile',
|
||||
};
|
||||
render() {
|
||||
const { navigate } = this.props.navigation;
|
||||
return (
|
||||
<Button
|
||||
title="Go to main"
|
||||
onPress={() =>
|
||||
navigate('Main')
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const AppNavigator = StackNavigator({
|
||||
Main: {screen: MainScreen},
|
||||
Profile: {screen: ProfileScreen},
|
||||
});
|
||||
|
||||
class AppComponent extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<AppNavigator navigation={addNavigationHelpers({
|
||||
dispatch: this.props.dispatch,
|
||||
state: this.props.nav,
|
||||
})} />
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const navInitialState = AppNavigator.router.getStateForAction(AppNavigator.router.getActionForPathAndParams('Main'));
|
||||
|
||||
const navReducer = (state = navInitialState, action) => {
|
||||
const nextState = AppNavigator.router.getStateForAction(action, state);
|
||||
return nextState || state;
|
||||
};
|
||||
|
||||
const appReducer = combineReducers({
|
||||
nav: navReducer,
|
||||
});
|
||||
|
||||
const mapStateToProps = (state) => ({
|
||||
nav: state.nav
|
||||
});
|
||||
|
||||
const App = connect(mapStateToProps)(AppComponent);
|
||||
|
||||
const store = createStore(appReducer);
|
||||
|
||||
class Root extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<Provider store={store}>
|
||||
<App />
|
||||
</Provider>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export { Root };
|
Loading…
Reference in New Issue
Block a user