In iOS, you can do rctRootView.appProperties = newProps, and it will update the root view with new props. On android it doesn't seem to be implemented.
This behavior is critical for my use case of incrementally adopting react native in a large android app.
I think I want a function like ReactRootView.updateProps(Bundle props) that would look something like
public void updateProps(Bundle newProps) {
WritableNativeMap appParams = new WritableNativeMap();
Double rootTag = MagicallyGetTheRootTag() // <- the rootTag isn't actually stored anywhere at the moment
appParams.putDouble("rootTag", rootTag);
appParams.putMap("initialProps", newProps);
final CatalystInstance catalystInstance = mReactInstanceManager.getCurrentReactContext().getCatalystInstance();
String jsAppModuleName = this.getJSModuleName();
catalystInstance.getJSModule(AppRegistry.class).runApplication(jsAppModuleName, appParams);
}
based on the startReactApplication fn
Before I made a PR I wanted to check my direction -- does it look reasonable? I think I'll have to store the rootTag on the ReactRootView instance, b/c I can't find anywhere else that it's already stored.
@bestander - could you check this out to see if it's reasonable? This is part of getting parity with iOS, cc @mkonicek
Will do on Tuesday
On Sunday, 6 March 2016, Brent Vatne [email protected] wrote:
@bestander https://github.com/bestander - could you check this out to
see if it's reasonable? This is part of getting parity with iOS, cc
@mkonicek https://github.com/mkonicek—
Reply to this email directly or view it on GitHub
https://github.com/facebook/react-native/issues/6303#issuecomment-192968644
.
:rocket:
@jaredly go for it, we would appreciate this feature.
Ping me with the PR.
ok so my initial attempt was unsuccessful (pretty much doing what I outlined above), and we've decided not to invest in RN yet, so it's unlikely I'll dig into this further in the near future
No worries, we'll do it eventually.
Would you mind giving feedback why you have decided to not proceed with RN right now?
Any particular pain or aspect you think we should address?
mostly immaturity of android, and to a lesser extent iOS. We have large apps that we're thinking of integrating react native into incrementally, which definitely isn't a well-documented use case. we're planning on doing further investigation in a few months and might have a different decision depending on how things have matured.
:+1:
Thanks, this gives some very important feedback.
@bestander What is the status of this feature request? My use case requires inserting a RN view in a native ListView. Removing and creating new react views doesn't allow for smooth scrolling and emitting events with prop updates sends the same props to all children.
Is the feature currently being worked on? If not, what might it involve to implement?
@MikeOrtiz nobody is working on it right now. feel free to send a pull request.
I want to get a data from Java to JS
bundle.putString("value", "aValue");
mReactRootView.startReactApplication(mReactInstanceManager, "IndexActivity", bundle);
but, I can not get the value from this.props.value
It sounds like this issue has played out, and we are keeping issues focused on bugs rather than feature requests at the moment, so I am going to close this issue. Feel free to send a pull request improving this though!
@brentvatne bump :P this is totally basic for having sane integration with an existing app
Bump this feature request. @brentvatne Or at least I think the lack of this feature on Android should be mentioned here: https://facebook.github.io/react-native/docs/communication-ios.html It will save people from mistakenly assuming that it exists for Android.
+1
Hi guys. Thank you for the amazing work you are doing with react.
Anyway i agree with @tianxind, someone should mention that Android is not ready to update props of a running component. I've lost half of my brain looking for a solution then a came here XD
Hi,
There is a method in ReactRootView called setAppProperties that does what is intended, I believe.
The problem is, like in iOS, the root component gets recreated instead of just updated (componentWillUnmount will be called and then the component will be recreated). Is this the intended behavior? Is there any way to just re-render the root component?
Most helpful comment
@brentvatne bump :P this is totally basic for having sane integration with an existing app