Turn off all edges?
See original GitHub issueI would like to be able to pass an empty array to the edges prop of SafeAreaView when I don’t want any safe area edges. The use case is a reusable component that on some screens I want it to take into account Safe Area, and other screens already take Safe Area into account and I don’t want double padding. So I’d like to pass a prop to my reusable component that can be used like so:
const MyComponent = ({ needsSafeArea }) => {
const edges = [];
if (needsSafeArea) {
edges.push('top');
}
return (<SafeAreaView edges={edges}>
{/* My cool component */}
</SafeAreaView>);
};
This code currently results in all edges being activated when needsSafeArea is false. If there’s a better way to handle my use case then please let me know.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:9
- Comments:6
Top Results From Across the Web
How to disable Edge - Microsoft Community
Hold down the Ctrl and Alt keys and tap the delete key, then click on Task Manager. If it says "More details" at...
Read more >How to Disable Microsoft Edge as Your Default Browser in 2022
Launch Microsoft Edge; Click the three dots in the top-right corner; Select “settings” ; Select “system” in the menu on the left side...
Read more >How to Disable Microsoft Edge on Windows 10 | SoftwareKeep
Method 2. Uninstall Microsoft Edge · Open the Settings app by clicking on the gear icon in the Start menu. · Click on...
Read more >How to Stop Microsoft Edge from Running in the Background ...
To stop it from running in the background first launch Microsoft Edge. Then click the Options button (three dots) and choose Settings from...
Read more >3 Easy Ways to Remove Edge Notifications - wikiHow
1. Open Settings. You can press the Windows key and I to open settings, or you can search for it in the search...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes this is a workaround, but not great because you either have to duplicate the code inside or create another layer of abstraction by factoring out the common code into yet another component. It would be much more readable and maintainable to just keep the SafeAreaView structure in place and control the behavior by props.
An empty edges array seemed intuitive to indicate no edges at first (before I re-read the docs), but probably it would be less disruptive to existing code if an optional flag was added called something like ‘disabled’.
I’ve also come to few use cases where I’d use that passing
edges={[]}
turns off all edges. It’s surprising to me it doesn’t, because the code clearly says what I want and that is to use no edges. If it would work like that and you would have opposite condition like “if something is true, I want onlytop
edge, otherwise use default edges” you could still do that byedges={condition? ['top'] : undefined}
, so to me it seems like win-win.Anyway, best workaround I found is to use
useSafeAreaInsets