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

179
Vistas
Where to get props and set props in a functional component in React Js?
props data coming from the parent component

const [state, setState] = useState({

reportTypesVal: { label: "", value: "" } || props?.reportTypesVal});

Why I'm unable to set data like this to reportTypesVal? If I try to set data in useEffect It doesn't set the value to reportTypesVal. How can I do this?

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

Your question is a bit unclear, but from the title:

Where to get props and set props in a functional component in React Js?

I assume you're asking how to pass props, here is an example on the new beta documentation: https://beta.reactjs.org/learn/passing-props-to-a-component

about 4 years ago · Juan Pablo Isaza Denunciar

0

You should implement it in the child name function.

EX:

import ...
import ...

function showSomething( {MyProps1, MyProps2} )  // <---- here
{
   useEffect(() => {
        
        console.log(MyProps1);      

   }
...
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

This is how you pass props into a component:

<Component property={'randomText'} />

This is how you retrieve it in the component:

function Component (props) = {
  return (
    <p>{props.property}</p>
  )
}

You can change the property inside of the component by using states and passing the set function as a property:

const [randomText, setRandomText] = React.useState('randomText')
return(
    <Component property={randomText} propertySet={setRandomText} />
)

Inside the component you can do:

function Component (props) = {
      return (
        <button onClick={() => {props.setRandomText('randomText2')}}>{props.randomText}</button>
      )
    }

Then when you click the button it will change to 'randomText2'

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