W
W
Wasya UK2019-05-08 20:44:18
React
Wasya UK, 2019-05-08 20:44:18

Why is email & password undefined?

At first I thought that maybe I connected the store incorrectly, but maybe the error is not in it? I went to the react-native-navigation dock and checked if everything was correct. But it still doesn't matter. What am I doing wrong?
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);

Answer the question

In order to leave comments, you need to log in

7 answer(s)
A
Anton Spirin, 2019-05-08
@dmc1989

Do not pass the mapStateToProps argument to connect.

N
NikolayAlb, 2017-04-18
@londhor

"I have never worked with PHP frameworks" and "1. Emphasis on speed" are mutually exclusive ;)
I.e. to write a truly optimized application - you have to study it a lot and deeply.

V
Vitaly Khomenko, 2017-04-19
@iiifx

> I didn't work with PHP frameworks at all > I don't
know the language very well
All the rake will be yours, no options. Take the framework that seems simpler and more understandable to you.

D
Denis Artamonov, 2017-04-19
@ArtamonovDenis

Phalcon
And fast, due to a one-time compilation in C (when the server starts).
And simple.
And the documentation has a good example of how to work with it.
-------------
I do not praise and do not impose. Yes, for an option.
-------------
In general, no matter what framework you take, it will not work without * sheep code .. And again, * sheep code - * sheep code - strife.
Even your current allegedly not * sheep code - in 0.5 - 1 year it will seem to you * sheep code.

T
ThunderCat, 2017-04-18
@ThunderCat

one
two
three
four
and think

N
Nokim, 2017-04-30
@Nokim

If you need to start quickly, then this one is very good: Fat-Free Framework
It seemed to me that the entry threshold is very low and fast enough (support for various caches out of the box). Very quickly, you can mold what you need, and if the project succeeds, then you can move on to something more serious.

F
fomiash, 2021-05-04
@fomiash

I need the framework to fit these points:
1. Emphasis on the speed of the framework. Higher is better.
2. Low entry threshold.
3. Fast development.
4. The ability to scale well, because I don’t know how long the project will shoot, and whether it will shoot at all.

The author of the question, most likely, has already implemented his idea, but I cannot but recommend a modern framework on these points .
1. Yes
2. Lower than usual. There is documentation in Russian.
3. It is better to ask about this in the support chat.
4. With the ability to initially build the architecture of the project correctly, you can scale without a framework, since its main task is to provide common tools for the web, usually this is routing.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question