我经历了多个React项目,但这是我第一次使用react-native。
我正在设置我的项目,但是不能使用商店。 这是我的代码。
index.js
import React, {Component} from 'react';
import {createStore, applyMiddleware, compose} from 'redux';
import {Provider} from 'react-redux';
import thunk from 'redux-thunk';
import rootReducer from './reducers/indexReducer';
import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(
rootReducer,
{},
composeEnhancers(
applyMiddleware(thunk)
));
class wrapRedux extends Component {
render() {
return (
<Provider store={store}>
<App />
</Provider>
)
}
};
AppRegistry.registerComponent(appName, () => wrapRedux);
App.js
import React, {Component} from 'react';
import {Text, View} from 'react-native';
import {createStackNavigator} from 'react-navigation';
import Login from './components/auth';
class HomeScreen extends Component<Props> {
render() {
return (
<View style={styles.container}>
<Text>APP</Text>
<Login/>
</View>
);
}
}
const RootStack = createStackNavigator({
Home: {
screen: HomeScreen
}
});
export default class App extends Component {
render() {
return <RootStack/>
}
}
尽管我正确地遵循了几个教程中找到的指南,但是我在React devTools,React Remote debugger甚至console.log(this.props)中都找不到商店。
请帮助我启动这个项目。
谢谢!