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

unstable_batchedUpdates undefined in React Native #127

Closed
amccloud opened this issue Aug 20, 2015 · 10 comments
Closed

unstable_batchedUpdates undefined in React Native #127

amccloud opened this issue Aug 20, 2015 · 10 comments

Comments

@amccloud
Copy link

I think RelayContainer depends on React.unstable_batchedUpdates which doesn't appear to be available under react-native. Instead it is React.addons.batchedUpdated.

@josephsavona
Copy link
Contributor

@zpao What is the best approach here?

@zpao
Copy link
Member

zpao commented Aug 20, 2015

This ties into the work that needs to be done to get react native all on board with react 0.14 and no longer providing their own override. (eg, you would do require('react') to create classes, the same way you do on web - that would be the isomorphic react, then require('react-native') gives you something else, like the renderer a la require('react-dom')).

cc @spicyj @sebmarkbage who have been working on this.

Not sure how far out that is, but perhaps React Native can just add unstable_batchedUpdates to their React overrride.

@sophiebits
Copy link
Contributor

Yes, the react-native package should expose that helper.

@sophiebits sophiebits changed the title batchUpdate undefined unstable_batchedUpdates undefined in React Native Aug 20, 2015
@amccloud
Copy link
Author

@zpao Gotcha. Explains why I had to alias react to react-native to use relay.

@timkrins
Copy link

Ran into this issue when working through the react-treasurehunt example on Windows.

I don't have a deep enough understanding to figure out why unstable_batchedUpdates is undefined, but I modifed injectBatchingStrategy in GraphQLStoreChangeEmitter.js to get the example to work properly.

injectBatchingStrategy: function injectBatchingStrategy(batchStrategy) {
  if(typeof batchStrategy != 'undefined' )
  {
    batchUpdate = batchStrategy;
  }
},

@timkrins
Copy link

Ah, my particular issue is fixed in commit 2d82240. Note, this was unrelated to React Native.

@sophiebits
Copy link
Contributor

On React Native you'll temporarily need to add a file called ReactDOM.js:

/**
 * @providesModule ReactDOM
 */

'use strict';

var ReactUpdates = require('ReactUpdates');

// Temporary shim required for Relay.
var ReactDOM = {
  unstable_batchedUpdates: ReactUpdates.batchedUpdates,
};

module.exports = ReactDOM;

but I was under the impression that the open-source Relay package has a couple other problems before it can be used directly in React Native…

@amccloud
Copy link
Author

@spicyj Very few. This was one of the main issues. I am successfully using relay with react-native. I use webpack so I aliased react to react-native. I also had to include https://github.com/johanneslumpe/react-native-browser-polyfill

@sophiebits
Copy link
Contributor

I'm not sure why you would need a self global…

@steveluscher
Copy link
Contributor

It looks like the original issue is fixed. Feel free to reopen or file a new task if there's more to be done here (other than that covered by #26).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants