Сначала подумал, что может неправильно подключил store, но может ошибка не в нем? Зашел в доку по react-native-navigation и переубедился все ли правильно. Но все равно не находит значения. Что я делаю не так?
reducers/user
import { ADD_USER } from "../actions/actionTypes";
const initialState = {
username: '',
password: ''
};
const reducer = (state = initialState, action) => {
switch (action.type) {
case ADD_USER:
return {
...state,
email: action.email,
password: action.password
}
break;
default:
return state;
}
};
export default reducer;
app
import configureStore from "./src/store/configureStore";
const reduxStore = configureStore();
// Register screens
Navigation.registerComponent('remote-control.AuthScreen', () => (props) => (
<Provider store={reduxStore}>
<AuthScreen {...props} />
</Provider>
), () => AuthScreen);
index
import { Provider } from "react-redux";
import configureStore from "./src/store/configureStore";
const store = configureStore();
const RNRedux = () => {
<Provider store={store}>
<App />
</Provider>
};
AppRegistry.registerComponent(appName, () => RNRedux);
screens/auth
import React, { Component } from "react";
import { connect } from "react-redux";
import axios from "axios";
import { addUser } from "../../store/actions/index";
const mapDispatchToProps = dispatch => {
return {
onAddUser: (email, password) => dispatch(addUser(email, password))
}
};
class Auth extends Component {
render() {
return (
<View>
<Text>{`${this.props.email}, ${this.props.password}`}</Text>
<DefaultInput placeholder="Email" value={this.state.email} onChangeText={this.changeEmailLoginData}/>
<DefaultInput placeholder="Password" value={this.state.password} onChangeText={this.changePasswordLoginData}/>
<DefaultButton onPress={this.loginHandler}>Sign in</DefaultButton>
</View>
);
}
}
export default connect(null, mapDispatchToProps)(Auth);