Skip to content

Conversation

@samuelhnrq
Copy link

Was not sure about the fix label maybe its a feature:

According to React Native Documentation Modules are singletons:

In React Native, Native Modules are singleton. The Native Module infrastructure lazily creates a Native Modules the first time it is accessed and it keeps it around whenever the app requires it

After confirming that, I propose we make the small change of moving the TurboModuleRegistry.getEnforcing<Spec>('DynamicTheme'); call from being the default export of NativeDynamicTheme.ts to instead being called on-demand after the already existing platform checks (e.g. inside the if).

Point being now the library can peacefully run in every other react native platform, Windows, Web, Vision OS, etc.

My change now makes (as I understand it) the ios code dead code, but I wanted to keep the PR focused.

Thanks.

@vercel
Copy link

vercel bot commented Sep 26, 2025

@samuelhnrq is attempting to deploy a commit to the fouadmagdy01's projects Team on Vercel.

A member of the Team first needs to authorize it.

@FouadMagdy01
Copy link
Owner

Thank you for your contribution, I understand your point, but the problem is that when you move the module from the spec file, the codegen will fail because it doesn't understand the type import
You will notice that the types used in the spec file are located at the same file so codegen can work peacefully, in order to make your code work you will also have to move the used types to the index.ts file, and tbh i dont want to do that because i want to make this file lean

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.

2 participants