Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] No API for updating props on android root component #6303

Closed
jaredly opened this issue Mar 4, 2016 · 17 comments
Closed

[Android] No API for updating props on android root component #6303

jaredly opened this issue Mar 4, 2016 · 17 comments
Assignees
Labels
Resolution: Locked This issue was locked by the bot. Type: Enhancement A new feature or enhancement of an existing feature.

Comments

@jaredly
Copy link
Contributor

jaredly commented Mar 4, 2016

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.

@Kureev Kureev changed the title No API for updating props on android root component [Android] No API for updating props on android root component Mar 4, 2016
@Kureev Kureev added the Android label Mar 4, 2016
@brentvatne
Copy link
Collaborator

@bestander - could you check this out to see if it's reasonable? This is part of getting parity with iOS, cc @mkonicek

@bestander
Copy link
Contributor

Will do on Tuesday

On Sunday, 6 March 2016, Brent Vatne notifications@github.com 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
#6303 (comment)
.

@brentvatne
Copy link
Collaborator

🚀

@bestander
Copy link
Contributor

@jaredly go for it, we would appreciate this feature.
Ping me with the PR.

@jaredly
Copy link
Contributor Author

jaredly commented Mar 9, 2016

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

@bestander
Copy link
Contributor

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?

@jaredly
Copy link
Contributor Author

jaredly commented Mar 10, 2016

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.

@bestander
Copy link
Contributor

👍
Thanks, this gives some very important feedback.

@MikeOrtiz
Copy link
Contributor

@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?

@satya164
Copy link
Contributor

satya164 commented Jun 7, 2016

@MikeOrtiz nobody is working on it right now. feel free to send a pull request.

@skeyboy
Copy link

skeyboy commented Aug 25, 2016

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

@lacker
Copy link
Contributor

lacker commented Nov 30, 2016

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!

@lacker lacker closed this as completed Nov 30, 2016
@jaredly
Copy link
Contributor Author

jaredly commented Feb 23, 2017

@brentvatne bump :P this is totally basic for having sane integration with an existing app

@tianxind
Copy link

tianxind commented Mar 9, 2017

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.

@SunburtReynolds
Copy link

+1

@tommasoresti
Copy link

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

@boliveira
Copy link

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?

@facebook facebook locked as resolved and limited conversation to collaborators Jul 20, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 20, 2018
@hramos hramos added the Type: Enhancement A new feature or enhancement of an existing feature. label Mar 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot. Type: Enhancement A new feature or enhancement of an existing feature.
Projects
None yet
Development

No branches or pull requests