Reg ToolbarAndroid
See original GitHub issueReact’s lean core effort is going full steam and now ToolbarAndroid is no longer available in the codebase though, as of today, the documentation does exist on the main doc site.
Examples in this repo that use ToolbarAndroid, like the Twitter sample, currently call it from react-native and this is bound to break in versions of react-native higher that v61, as i found out as well in my project.
Please let me know if you are considering shipping an Android variant sometime in the future.
Pitches for having it in the library:
Navigation React Nativedoes have an iOS variant (inTitleBarIOSI think) so it can balance things out- it is a key and recognizable UI artefact that perhaps is firmly tied in in premises of router solutions
- my project uses it 😃. Actually i suspect a rather high percentage of projects expect to use some form of a toolbar since it is a natively available across platforms and predictably familiar to users
To get a feel of Android native module integration with the router, my initial attempts at a crude/copy-paste integration results in errors currently. I get the dreaded ‘Invariant Violation’ error (“expected a string for built-in components…you likely forgot to export your component from the file it is defined in…”). I think i did the right things, at least after cross-checking with how the other modules - like the tabs - were integrated, but somehow i keep getting the error i mentioned above.
Steps i undertook:
- i pulled the relevant java code/source from an earlier
react-nativerelease, dumped them into atoolbardirectory injava/com/navigation/reactnative. The files created areDrawableWithIntrinsicSize.java,ReactToolbar.javaandReactToolbarManager.javain the roottoolbardirectory and in a nestedeventsdirectory i haveToolbarClickEvent.java. The code is verbatim from an earlier react-native version that did have the implementation. - updated the
NavigationPackage.javafile with the import:import com.navigation.reactnative.toolbar.ReactToolbarManager;and subsequent call tonew ReactToolbarManager(). - the build works fine and i copy the new
navigation-react-nativedirectory to mynode_modules - despite not being type-defined as yet i went ahead with a named import of
ToolbarAndroidfromnavigation-react-nativeand attempted calling it in one of my components with a simple<ToolbarAndroid title="Home" />
Im still not to sure if just pulling in the code as-is from an earlier version somehow messes up the licensing bit even if the comments and attributions are intact. My guess is it should be ok for FOSS projects.
This original ToolbarAndroid module is quite comprehensive and if indeed you are looking at having a common Toolbar component across platforms across both the platforms, some rationalization or simplification may be warranted i think.
If you are not too keen on having it integrated i can always use the same approach but have it exposed via NativeModules. It perhaps may work. Or may not. Or maybe totally simplify it just for for my needs -> a back button, a title and perhaps a menu button/icon
UPDATE:
I have to make a few changes to .tsx files as well. Will update here after completing those.
Issue Analytics
- State:
- Created 4 years ago
- Comments:51 (50 by maintainers)

Top Related StackOverflow Question
I open a PR for this issue. Hope this helps!
Fixed by #311