Skip to content

refactor: do not rely on deep imports#1000

Merged
kirillzyusko merged 4 commits intomainfrom
refactor/do-not-rely-on-deep-imports
Jul 1, 2025
Merged

refactor: do not rely on deep imports#1000
kirillzyusko merged 4 commits intomainfrom
refactor/do-not-rely-on-deep-imports

Conversation

@kirillzyusko
Copy link
Copy Markdown
Owner

@kirillzyusko kirillzyusko commented Jul 1, 2025

📜 Description

Don't rely on deep imports and provide a warning free compatibility with RN 0.80+ (by utilizing a more official and reliable way to substitute native module implementation).

💡 Motivation and Context

Originally implementation substitution was implemented in #30

Starting from react-native@0.80 deep imports were deprecated and now if you try to use them you get a warning:

Deep imports from the 'react-native' package are deprecated

In version 0.82 the ability to use deep imports will be completely removed. In preparation of that RN team opened a discussion on GitHub about those upcoming changes.

This library uses deep imports to substitute StatusBar implementation. I opened a thread to discuss how we can overcome it. While waiting for a proposed solution I discovered, that we can override native modules with own implementation - this is the case that I want to use. I want to substitute the implementation of StatusBar and fallback to default implementation if EdgeToEdge view is disabled.

📢 Changelog

JS

  • remove monkey-patch code;

Android

  • rename StatusBarManagerCompat to StatusBarManager to match name of original module;
  • added getConstants method;
  • StatusBarManagerCompat now can override existing modules;
  • make active prop public;
  • make setActive setter field-setter to avoid compilation conflicts;
  • StatusBarManagerCompat now respects active props and fallbacks to StatusBarManager implementation if edge-to-edge view is disabled;
  • added helpers like isEnabled/view to StatusBarManagerCompat to reduce code duplication.

🤔 How Has This Been Tested?

Tested manually on:

  • Pixel 7 Pro (API 36, real device);
  • Pixel 3A (API 33, emulator);

📸 Screenshots (if appropriate):

Screen.Recording.2025-07-01.at.19.51.45.mov

📝 Checklist

  • CI successfully passed
  • I added new mocks and corresponding unit-tests if library API was changed

@kirillzyusko kirillzyusko self-assigned this Jul 1, 2025
@kirillzyusko kirillzyusko added 🤖 android Android specific refactor You changed the code but it didn't affect functionality labels Jul 1, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jul 1, 2025

📊 Package size report

Current size Target Size Difference
207199 bytes 211103 bytes -3904 bytes 📉

@kirillzyusko kirillzyusko marked this pull request as ready for review July 1, 2025 16:51
@kirillzyusko kirillzyusko merged commit ecb3595 into main Jul 1, 2025
24 of 25 checks passed
@kirillzyusko kirillzyusko deleted the refactor/do-not-rely-on-deep-imports branch July 1, 2025 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖 android Android specific refactor You changed the code but it didn't affect functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant