Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

94
Views
Access props of imported component in React

How could I pass/access the props of an imported component? This example component comes from a third-party library, so I'm not sure how I'd go about getting its props

import { Example } from './comps' 
    
const App = () => {
  return (
    <Example />
  );
  console.log(Example.props) //this returns undefined 
}

export default App;
almost 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You cannot access props of a child Component from parent Component in that way.
Moreover:

const App = () => {
  return ( // return will finish the function, so the console.log below doesn't make any sense.
    <Example />
  );
  console.log(Example.props) //this returns undefined 
}

In your example, props is the things passed from App, so you can pass/access directly from App:

const App = () => {
  const [value, setValue] = useState(0);

  return (
    <Example number={value} setNumber={setValue} />
  );
}
almost 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!