Repository navigation
feat: add DebugView to visualize safe area insets - #812
Open
officialasishkumar wants to merge 1 commit into
Open
officialasishkumar wants to merge 1 commit into
officialasishkumar wants to merge 1 commit into
Conversation
Add a development helper that draws the insets of the nearest SafeAreaProvider as labeled, translucent bands over its parent. It is absolutely positioned and never intercepts touches, and supports a custom color and hiding the labels. As discussed in appandflow#68, it is not exported from the package entry point since React Native does not tree shake. It is published as the react-native-safe-area-context/DebugView subpath, using root level DebugView.js / DebugView.d.ts shims in the same way as jest/mock. Includes tests and an API docs page.
|
@officialasishkumar is attempting to deploy a commit to the appandflow Team on Vercel. A member of the Team first needs to authorize it. |
floco-af
reviewed
Nov 13, 2026
floco-af
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the PR, and for following the subpath approach suggested in #68. Review below, from a maintainer-side bot run (not a human approval).
Validation (JS only, on the PR branch at 852fe2e)
jest: 6 suites pass (35 passed, 2 skipped), including the newDebugView-test.tsx. The base branch has 5 suites, so the added suite is the only difference.tsc --noEmit,eslintandprettier --checkon the changed files are clean.bob buildemitslib/commonjs/DebugView.js,lib/module/DebugView.jsandlib/typescript/src/DebugView.d.ts.npm pack --dry-runlists the rootDebugView.js/DebugView.d.tsshims, soreact-native-safe-area-context/DebugViewresolves the same way asjest/mock.- Not validated: rendering on a real iOS/Android device or web. There is no screenshot in the PR, and this run did not do a native repro either. A before/after screenshot on a notched device (portrait and landscape) would help.
Looks good
- Not exported from the main entry point, as agreed in #68, so apps that don't use it don't bundle it.
- Small, contained diff, with tests and a docs page.
Minor suggestions (non-blocking)
- The left/right bands span the full height (
top: 0, bottom: 0), so they overlap the top/bottom bands and the corners render darker. Constraining them between the top and bottom insets would give cleaner output. - The label is hard-coded
white, so it is hard to read with a light customcolor. AlabelColorprop (or a contrasting default) would help. - Labels in the left/right bands are clipped when the inset is narrow (
overflow: 'hidden',numberOfLines={1}, and a 0-3 px band on devices without side insets). That is fine for 0, but a vertical or offset label would be more legible in landscape. pointerEventsis passed as a prop.react-native-webwarns that this is deprecated in favor ofstyle.pointerEvents, so it is worth checking the web console. Also,{...others}after it lets callers override it, which seems intended.- The docs
sidebar_position: 11leaves a gap afterdeprecated(9). Not a problem, just flagging. - The test only imports from
../DebugView. A small test of the rootDebugView.jsshim (or a check in the build) would catch broken subpath packaging later.
cc @janicduplessis for the final call on API naming and whether this belongs in the package.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #68. Adds a
DebugViewdevelopment helper that draws the safe area insets of the nearestSafeAreaProviderover its parent, so developers can check visually how their layout interacts with the safe area.pointerEvents="none".top: 47). Props:colorandshowLabels, plus allViewprops.react-native-safe-area-context/DebugViewsubpath, through rootDebugView.js/DebugView.d.tsshims added tofiles, the same wayjest/mockworks.Test Plan
src/__tests__/DebugView-test.tsx(band geometry/size per edge, labels, no touch interception, custom color, hiding labels).jest(all suites pass),tsc --noEmit,eslintandprettier --checkon the changed files are clean.bob buildemitslib/commonjs/DebugView.jsandlib/typescript/src/DebugView.d.ts, which the root shims point at.