react-native icon indicating copy to clipboard operation
react-native copied to clipboard

[Android][UIManager] Controlling ReactRootView from js

Open lklots opened this issue 11 years ago • 5 comments

I have a hybrid RN app that uses a ReactRootView inside a native UI. The layout looks as follows:

TabLayout
ReactRootView
RecyclerView

I want to allow the JS to animate the ReactRootView in and out depending on whether there is something to show. I tried using the UIManager but it does not seem to expose the root view to JS land. The only allowed operation is removing the root. Would a PR request to allow modifying the root view properties be accepted?

If not, what is a good way to go about this? My current hacky solution is to create a NativeModule that allows adhoc modification of the root view based on the rootTag variable available in JS land.

lklots avatar Nov 16 '15 01:11 lklots

cc @mkonicek

brentvatne avatar Nov 20 '15 07:11 brentvatne

Another interesting issue came up. I want my root view to be gone unless there is something to show. So ideally I would have my root view visibility set to GONE, execute some JS code, and then have the JS change the root view visibility to VISIBLE when there is something to show.

The problem is that no JS code can be executed unless onMeasure() executes. And onMeasure won't execute if the view is GONE. It's not unreasonable default behavior but the issue is that there is no way to force startApplication() to actually execute. If I try to force the onMeasure() call I a GONE view then I am faced with an exception thrown by ReactRootView about incorrect layout properties.

I am not sure what a good solution is here. But it should be possible for a GONE root view to execute some JS without resorting to hacks.

lklots avatar Nov 20 '15 07:11 lklots

Actually @javache seems like a good person for this :) And maybe @dsibiski

brentvatne avatar Nov 21 '15 02:11 brentvatne

@mkonicek , thoughts?

lklots avatar Dec 01 '15 22:12 lklots

Hi there! This issue is being closed because it has been inactive for a while.

But don't worry, it will live on with ProductPains! Check out its new home: https://productpains.com/post/react-native/androiduimanager-controlling-reactrootview-from-js

ProductPains helps the community prioritize the most important issues thanks to its voting feature. It is easy to use - just login with GitHub.

Also, if this issue is a bug, please consider sending a PR with a fix. We're a small team and rely on the community for bug fixes of issues that don't affect fb apps.

mkonicek avatar Apr 10 '16 16:04 mkonicek