Dismissing partial modals

Dismissing partial modals

While you write your awesome UI, there will be times when we will encounter a bunch of external UI libraries and components. Most of the times they will have a good API and will be able to cover most of the cases. In certain edge cases you will run into a situation where touching outside the boundary of the component will not trigger a keyboard collapse or modal dismiss. For such cases one potential solution is to attach a Responder to the background Views in such a way that it will capture such touches and respond accordingly.

Touch events in React Native are managed by the Responder System. The Responder System is an abstraction on top of the underlying touch events that allows components to manage touch interactions in a more granular way.

The onStartShouldSetResponder prop accepts a function that is invoked when a touch event is initiated. This function should return true if the component should become the responder for this touch event, or false if it should not. By returning false but executing our side effect beforehand we ensure that the gesture flow does not get affected beyond the scope of what we need.

This will make the UX so much more better and allow things to work in a manner that the users have become used to via other Apps.

To view or add a comment, sign in

More articles by Nikit P.

  • Swiss tables are NOT the endgame

    Introducing CAPH: Constant-time Additive Probabilistic Hashing For the last ~7 years, Swiss Tables have been treated as…

  • Why “The Algorithm Did It” Won’t Fly Much Longer

    Every Organization Deploying AI Needs a System Liability Engineer Or: Why "The Algorithm Did It" Won't Fly Much Longer…

  • REWA: Witness-Overlap Theory

    Excited to drop my latest: REWA: Witness-Overlap Theory – the game-changer ditching dense vectors for snappy binary…

    1 Comment
  • Do we now need LLM compatible programming languages?

    Last year has seen an explosion in the arena of LLMs. They have indeed proven to be very useful.

  • JSI In react native

    Performance. Performance.

  • The Disappearing NavBar

    When you are scrolling on the screen on a mobile App, you must have observed this really funky transition where the…

  • Emergent properties

    We are going to be hearing about this term time and again in the coming future. What makes ChatGPT so useful is not its…

  • The native driver Conundrum

    In React Native, useNativeDriver is a property that you can set when you are animating elements in your app. It…

  • Optimizing React Native Performance: A Closer Look at Object Literals

    React Native has established itself as one of the most popular frameworks for building cross-platform mobile…

  • The power of giving up! *

    Yes you read that right. Its contrarian to everything you have ever read but hear me out.

    3 Comments

Explore content categories