-
Notifications
You must be signed in to change notification settings - Fork 50.5k
Description
I'm still quite new to React, but I guess this is a bug in the React framework introduced in 0.14. Seems like all listeners attached with JSX are broken in native Android browser for Android LTE 4.3, when compiling code with NODE_ENV development. Everything works fine with NODE_ENV production compilation.
I've tracked it down to being related to ReactErrorUtils, that in development mode do guards on events. The source code:
https://github.com/facebook/react/blob/0.14-stable/src/shared/utils/ReactErrorUtils.js#L58-L74
If I simply remove that part of code after compiling the React app, the listeners starts working again. I guess this is not intentional, but instead a bug?
To reproduce problem in Android LTE 4.3 (code that works in e.g. Chrome Browser):
- Using the pre-compiled Getting Started lib https://facebook.github.io/react/downloads/react-0.14.0.zip:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Hello React!</title>
<script src="build/react.js"></script>
<script src="build/react-dom.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script>
</head>
<body>
<div id="example"></div>
<script type="text/babel">
console.log('Script init');
var testClick = function (e) {
e.preventDefault();
console.log('test click!');
};
ReactDOM.render(
<div>
<a href="#" onClick={testClick}>JSX onClick!</a><br />
<a href="#" id="manual-attach">Manually attached onClick</a>
</div>,
document.getElementById('example')
);
document.getElementById('manual-attach').addEventListener('click', function (e) {
e.preventDefault();
console.log('test manual click attach!');
})
</script>
</body>
</html>