Skip to content

Small suggestion about #178 #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Small suggestion about #178 #179

wants to merge 1 commit into from

Conversation

Lee-WonJun
Copy link

@Lee-WonJun Lee-WonJun commented Jun 17, 2025

Description

Extract the client-environment check into a new, exported isClientEnvironment() helper so tests can mock it directly, without changing any runtime behavior or throwing errors.

As this is not intended as a patch but rather a small enhancement, I avoided adding any breaking behaviors like throwing errors to ensure full backward compatibility.

Related Issue: Fixes #178

Changes

  • Add and export isClientEnvironment() util
  • Have useClientLayoutEffect call it and return early when false (non-changed behavior)
  • No other logic or error-throwing changes—existing behavior is untouched

Motivation and Context

// jest.setup.js
global.navigator = { product: 'ReactNative' };

Patching global.navigator in jest.setup.js is a pretty good workable solution, but it feels a bit weird and like a global workaround.

By extracting and exporting the check, we enable targeted jest.mock()/jest.spyOn() of exactly that function (and it makes the [overlay-kit] repo itself more testable)

While I’m not primarily a frontend engineer and may not be fully familiar with the canonical idioms, I believe this small suggestion maintains full backward compatibility, introduces no runtime changes, and allows for more flexible testing.

How Has This Been Tested?

I didn’t find dedicated tests for this hook, so I’ll check the CI test results after opening the PR.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have performed a self-review of my own code.
  • My code is commented, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • Any dependent changes have been merged and published in downstream modules.

Further Comments

@Lee-WonJun Lee-WonJun requested a review from jungpaeng as a code owner June 17, 2025 14:52
Copy link

changeset-bot bot commented Jun 17, 2025

⚠️ No Changeset found

Latest commit: dc5d4b1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Jun 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
overlay-kit ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 17, 2025 2:53pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Explicitly throw an error when overlay-kit cannot be used
1 participant