Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

138
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda