WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.49k stars 4.19k forks source link

@wordpress/react-native-bridge #59939

Open MuflahNasir opened 7 months ago

MuflahNasir commented 7 months ago

Currently, this package is not available on npm. And @wordpress/compose uses this package in one of its hooks. So when I installed @wordpress/compose I got this error while running a mobile app.

Unable to resolve "@wordpress/react-native-bridge" from "../../node_modules/@wordpress/compose/src/hooks/use-network-connectivity/index.native.js".

So when are you going to publish this package to npm? And what is the temporary workaround for this problem?

Mamaduka commented 7 months ago

cc @WordPress/native-mobile

MuflahNasir commented 7 months ago

is this an npm package?

Mamaduka commented 7 months ago

@MuflahNasir, it looks like it's unpublished package, but that's all the information I've. I pinged the team working on the mobile apps.

derekblank commented 7 months ago

@MuflahNasir Correct, @wordpress/react-native-bridge is not currently published to npm.

The temporary workaround would be to install the package in your project to use locally:

npm install ./gutenberg/packages/react-native-bridge --save

There are two hooks in @wordpress/compose that use @wordpress/react-native-bridge as a dependency:

I am not certain if there are plans to publish @wordpress/react-native-bridge. Perhaps it may be better to remove these two hooks from @wordpress/compose and relocate them somewhere else. We can continue the discussion with the rest of the native mobile team on this thread.

fluiddot commented 7 months ago

I am not certain if there are plans to publish @wordpress/react-native-bridge. Perhaps it may be better to remove these two hooks from @wordpress/compose and relocate them somewhere else. We can continue the discussion with the rest of the native mobile team on this thread.

Seems that both hooks useNetworkConnectivity and usePreferredColorScheme are not referenced in the documentation and the package react-native-bridge is not declared as a dependency in compose. Taking this into consideration, plus the fact that the hooks are specific to the mobile native version, makes me wonder if the hooks should be relocated in a different package.

dcalhoun commented 7 months ago

I agree that relocating the two Hooks in question is likely the best approach. The current setup also results in a cyclic dependency via the react-native-aztec package. Relocating the Hooks might also address that cycle.

derekblank commented 7 months ago

Sounds good. I'll work on moving these hooks somewhere more suitable.

derekblank commented 7 months ago

The wordpress/@editor package seemed like the most obvious package to relocate useNetworkConnectivity to, as that package is currently the only place where the hook is used. I've created a draft PR for that change in https://github.com/WordPress/gutenberg/pull/59982, but am open to feedback on the structure.

usePreferredColor (and usePreferredColorScheme) are used in several other packages, however. Any thoughts on a good candidate to relocate this hook to?

fluiddot commented 7 months ago

The wordpress/@editor package seemed like the most obvious package to relocate useNetworkConnectivity to, as that package is currently the only place where the hook is used. I've created a draft PR for that change in #59982, but am open to feedback on the structure.

If the hooks are specific to the mobile native version and they require the module react-native-bridge, I wonder if they should be relocated to react-native-editor. My rationale is that react-native-editor is the central point of editor-level logic specific to the mobile native version. WDYT?

derekblank commented 7 months ago

I wonder if they should be relocated to react-native-editor.

Good suggestion. I'll check the structure of react-native-editor to see how we might relocate these hooks to that package.

MuflahNasir commented 2 months ago

Do we have any updates about this issue. I am getting this issue on Android too.

Unable to resolve "@wordpress/react-native-bridge" from "../../node_modules/@wordpress/compose/src/hooks/use-preferred-color-scheme/index.android.js"

dcalhoun commented 2 months ago

@MuflahNasir there are no updates at this time. https://github.com/WordPress/gutenberg/pull/59982 was drafted to address the issue, but has not progressed to approval or merge.

Currently, there are fewer individuals actively contributing to the native mobile editor. I'm unsure of when we might finish addressing this. If I am able to find time, I will try to move things forward.