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

409
Views
How can I press a button from within another touchable/pressable? [React Native]

I have the LoginButton component provided by react-native-fbsdk-next used on my login screen. What I want to do is perform a network check using a custom hook when the user attempts to press this button, before initiating the sign-in flow that component performs when pressed. I am trying to wrap the button in a custom TouchableOpacity (or something like that -- see code below), but I am not sure how (if it is even possible) to press the button after the network check completes without requiring another press from the user. Any ideas?

This is the button on my login screen with the wrapper I hope to implement.

<CheckNetworkWrapper>
    <LoginButton
        onLoginFinished={handleFBLoginPress}
        style={
            Platform.OS === "ios"
                ? {
                      width: deviceWidth * 0.85,
                      height: deviceHeight * 0.049,
                  }
                : {
                      height: deviceHeight * 0.04,
                      width: deviceWidth * 0.48,
                  }
        }
    />
</CheckNetworkWrapper>

This is my yet-to-be-fully-implemented CheckNetworkWrapper component.

export default function CheckNetworkWrapper({ button, buttonFunc, style }: Props) {
    const checkNetwork = useNetworkCheck();

    return (
        <TouchableOpacity onPress={checkNetwork(buttonFunc)} style={[style, { opacity: 1 }]}>
            {button}
        </TouchableOpacity>
    );
}

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

0

What you are trying to do is not going to work cause you can't 'avoid' the touch event from firing on the LoginButton component.

What you can do is to create your own button and you can style it so it looks like the Facebook one. Then in the method that handles the click you can first check for network and then if it's all good you can use the Facebook Login Manager to login.

Optionally, the LoginButton does have an onError event that I'm pretty sure you could use to catch a network error.

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!