Skip to content

JSX listeners broken in React 0.14 for Android LTE 4.3 with NODE_ENV='development' #5153

@daniellervik

Description

@daniellervik

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):

<!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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions