Skip to content

Instantly share code, notes, and snippets.

@romac
Last active August 29, 2015 14:00
Show Gist options
  • Save romac/11111288 to your computer and use it in GitHub Desktop.
Save romac/11111288 to your computer and use it in GitHub Desktop.

Trying to reproducing the

ReactUpdates: must inject a batching strategy

error I've been getting when updating the state of the root component, with React built as an external module with browserify.

  1. Run make
  2. Put console.log('ReactUpdatesInjection.injectBatchingStrategy', _batchingStrategy); inside ReactUpdatesInjection.injectBatchingStrategy (grep for injectBatchingStrategy: function(_batchingStrategy)) in both prod.js and react.js.
  3. Open dev.html and prod.html
  4. Both files show the above console.log output, which means that injectBatchingStrategy has been successufully called in both cases, and leads me to think that the issue might be with react-router-component not playing well with browserify. I will investigate further and update this Gist.
/** @jsx React.DOM */
var React = require('react');
React.renderComponent(
<h1>Hello, world!</h1>,
document.getElementById('example')
);
<!DOCTYPE html>
<html>
<head>
<title>Dev</title>
</head>
<body>
<div id="example"></div>
<script src="react.js"></script>
<script src="dev.js"></script>
</body>
</html>
SHELL = bash
BIN_DIR = ./node_modules/.bin
BROWSERIFY = $(BIN_DIR)/browserify
.PHONY: all clean
all: prod.js dev.js
prod.js:
@echo -n "Building $@... "
@$(BROWSERIFY) -t reactify app.js > $@
@echo "Done."
dev.js: react.js
@echo -n "Building $@... "
@$(BROWSERIFY) --debug -x react -t reactify app.js > $@
@echo "Done."
react.js:
@echo -n "Building $@... "
@$(BROWSERIFY) -r react > $@
@echo "Done."
clean:
rm -f react.js dev.js prod.js
{
"name": "react-extern",
"version": "0.0.1",
"description": "",
"private": true,
"keywords": [],
"author": "Romain Ruetschi ([email protected])",
"license": "MIT",
"devDependencies": {
"reactify": "~0.9.1",
"browserify": "~3.33.1"
},
"dependencies": {
"react": "~0.10.0"
}
}
<!DOCTYPE html>
<html>
<head>
<title>Prod</title>
</head>
<body>
<div id="example"></div>
<script src="prod.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment