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

161
Views
What the function type in Reac-Native

I have a function as below:

  const myFunction = () => () => {
       //do something
    }

Does anyone help me explain what's means the function as above.

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

0

It's a function that returns a function. An example of where you might use this would be to reduce repetition when you need a set of similar callback functions. Here's an example from a recent React Native app that I've worked on: Consider a pocket calculator app that has a grid of similar buttons, each with an onPress callback that needs a distinct value to be used in the callback function:

// Snippet from React component
...
const onPress = value => () => {
  console.log('You pressed ' + value);
}

return (
  <>
    <Button title="ONE" onPress={onPress(1)} />
    <Button title="TWO" onPress={onPress(2)} />
    <Button title="THREE" onPress={onPress(3)} />
  </>
)

Each button gets an onPress callback function with a ()=>{} signature, as required, that does something with a distinct value. Rather than having to declare three functions, we've just declared one. Nice and tidy.

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!