Open vladp opened 10 months ago
Same problem here. When we downgrade to React Native 0.71 it works fine, but after upgrading to 0.72 ToolbarAndroid becomes broken.
@vanHoi thank you for the confirmation. I cannot move back to prev react-native version, unfortunately. I had just completed a bunch of upgrades related to Expo (another big dependency I have, and when I changed back to prev react version, due to Expo changes, I could not even build with 0.71x). @EvanBacon is there a chance that this module would be made compatible with React native 0.72x >
I used patch-package with this diff to get it to work on React Native 0.72:
diff --git a/node_modules/@react-native-community/toolbar-android/js/ToolbarAndroidNativeComponent.js b/node_modules/@react-native-community/toolbar-android/js/ToolbarAndroidNativeComponent.js
index 07f9e20..cc51d1c 100644
--- a/node_modules/@react-native-community/toolbar-android/js/ToolbarAndroidNativeComponent.js
+++ b/node_modules/@react-native-community/toolbar-android/js/ToolbarAndroidNativeComponent.js
@@ -10,7 +10,7 @@
'use strict';
-const requireNativeComponent = require('react-native/Libraries/ReactNative/requireNativeComponent');
+const {requireNativeComponent} = require('react-native');
import type {SyntheticEvent} from 'react-native/Libraries/Types/CoreEventTypes';
import type {ImageSource} from 'react-native/Libraries/Image/ImageSource';
I don't know if this is backwards compatible with older versions otherwise I'd submit a PR.
@ieatfood your one line fix in this component -- fixed the issue! How did you figure this out, if I may ask? Was there an API change announcement on react-native side that indicated that this change is needed?
I would certainly submit PR because as of now this component is not working with recent version of react native. May be the maintainers @EvanBacon @vanHoi will create appropriate version for this update, that does not impact react-native users of the pre 0.72 releases.
Error on line 230, column 24 in ToolbarAndroid.android.js (see screenshot for error message) '.. requireNativeComponent is not a function it is an object'
package.json
Activity invoking the React native (using autolinking, and I confirmed that packages ).
com.reactnativecommunity.toolbarandroid.ReactToolbarPackage;
is included in the array of packages (ListClass where I use the tool bar:
I am using Hermes java script engine. More info on the enviroment
See screen shot for the error location