0
Good afternoon guys I’m beginner and I’m having a problem when it comes to updating my state could help me or give some hint on how I can fix this
Home js.
import React from 'react';
import {Form, Button,Container} from 'react-bootstrap'
import {connect} from 'react-redux'
import {Link} from 'react-router-dom'
function getUsuario(usuario,action){
return {
type:'PEGAR_USUARIO',
usuario:action.usuario,
}
}
const FormLogin = ({usuario,dispatch}) => (
<Container>
<Form>
<Form.Group controlId="formBasicEmail">
<Form.Label>Usuario</Form.Label>
<Form.Control type="text" placeholder="Usuario" onChange={(e)=>{ e.target.value}} />
</Form.Group>
<Form.Group controlId="formBasicPassword">
<Form.Label>Senha</Form.Label>
<Form.Control type="password" placeholder="Senha" />
</Form.Group>
<Form.Group controlId="formBasicCheckbox">
</Form.Group>
<Link to="/home" onClick={()=> {dispatch(getUsuario(usuario))}}>
<Button variant="primary" type="submit" >
Entrar
</Button>
</Link >
</Form >
</Container>
)
export default connect(state => ({usuario: state.usuario}))(FormLogin);
store js.
import {createStore} from 'redux'
const INITIAL_STATE =
{
usuario: ''
}
function reducer(state = INITIAL_STATE , action){
console.log(action)
if(action.type === 'PEGAR_USUARIO'){
return {...state, usuario:action.usuario}
}
return state;
}
const store = createStore(reducer);
export default store;
But what is the specific error? If you log in to Reset, you don’t get there?
– Andrew Ribeiro
What I need is for the input value to be stored in my state but it does not store the state value never changes
– Filipe Nickel Sala