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

109
Vistas
How to pass data from class React.Component to jsx file

I have a class with form and I want to pass entered data to next jsx file =>

Here is class ("sender")

import React from 'react'
import Button from './Button';

class Sender extends React.Component {
    constructor() {
        super();
        this.state = {
          imie: '',
        };
        
        this.redirect = this.redirect.bind(this);
        this.handleChange = this.handleChange.bind(this);
      }
      handleChange({ target }) {
        this.setState({
          [target.name]: target.value
        });
      }
      getData(){
        const sendData = [
            {
                name: this.state.name
            }
        ]
      }
    render() {
        return (
                <div className="order-wrapper">
                    <div className="order">
                        <div className="order-box">
                            <label htmlFor="name">Imie: </label>
                            <input 
                            type="text" 
                            name="name" 
                            id="name" 
                            value={ this.state.name }
                            onChange={ this.handleChange } 
                            />
                        </div>
                        <div className="order-box">
                            <Button 
                            type="submit"
                            value="Zamów"
                            className="zamowbtn"
                            onClick={this.redirect}
                            />
                        </div>
                    </div>
                </div>
            </div>
        )
    }
}

export default Sender

From this class I want to send name value which is located in getData() function.

I need that value in .jsx file below and show it in console.log(). How to do it? Please help me:)

import React from 'react'
import Sender from './Sender'

const Finish = () => {
  
  return (
    <div>
      { /* Here i need my 'name' value from Sender Class */ }
    </div>
  )
}

export default Finish
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If there are in different parts of Application and one is not a parent of second one. You should use Context API for this

about 4 years ago · Juan Pablo Isaza Denunciar
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