Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

132
Vistas
React-Redux :- I want to Show data when Form gets Submitted

When I submit form the data should display on other page . How I can get the data from redux store in functional component and show the display on page I have created 2 components one is App.js and other one is Showdata.js , when I click on Submit then the page redirect to Showdata.js component then the submitted data get display.

import {useEffect} from "react"
import {useNavigate} from 'react-router-dom'
import { Link } from "react-router-dom";
import { getContact } from "./action/contactAction";
import { connect} from 'react-redux';
// import Store from "./store/configure";

function Showdata(props){
    const nav = useNavigate();
    const onUnload=()=>{
        nav("/");        
    }
    // useEffect(()=>{
    //     window.addEventListener("beforeunload",onUnload);
    //     return()=>{
    //         window.removeEventListener("beforeunload",onUnload);
    //     }
    // },[])
   function createListIteams(){
        return props.contacts.map((contacts)=>{
            return<li>
                {contacts.firstname}</li>
        });
    }
       
    return(
         
        <div>
            <ul>
                {createListIteams()}
            </ul>
            <h1>
            <button className="btn btn-primary"  onClick={onUnload}><Link to='/'></Link>Home</button>
            </h1>
            
        </div>
    )
}
const mapStateToProps=(state)=>{
    // console.log(state)
 
    return{
        contacts:state.formData
        
    }
};

const mapDispatchToProps=(dispatch)=>{
    
    return{
        getContact: contact =>dispatch(getContact(contact))
        
    }
};

export default connect(mapStateToProps,mapDispatchToProps)(Showdata);
 // This is the Showdata.js File and I want to access the redux Store data and get that data and Display.
about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda