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

107
Views
React Passing object and callback as props

I'm a little new to react. I would like to pass down two props to a component, One is an object and another is a callback

function App(props) {
      var [data, setData] = useState([]);
          var [filters, setFilters] = useState([])
        
          const filtersCallback = useCallback((filter) => {
            setFilters(filters);
          }, []);
        
        
          useEffect(() => {
            axios.get(props.api).then(res=>{
              setData(res.data)
            })
          }, [])
        
    return(<Component {...data} filtersCallback={callback}/> )

This won't work, and I'm not quite sure how else this can be achieved. I also couldn't find a solution anywhere else

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If back-end return model change your hook defination like

var [data, setData] = useState({});
about 4 years ago · Juan Pablo Isaza 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!