Skip to content

Instantly share code, notes, and snippets.

@samspot
Last active September 15, 2016 09:26
Show Gist options
  • Save samspot/8837797 to your computer and use it in GitHub Desktop.
Save samspot/8837797 to your computer and use it in GitHub Desktop.
reactjs test for android
<!doctype html>
<html>
<head>
<!--
<script src="http://cdnjs.cloudflare.com/ajax/libs/es5-shim/2.2.0/es5-shim.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/es5-shim/2.2.0/es5-sham.js"></script>
<script src="http://fb.me/react-0.8.0.min.js"></script>
<script src="http://fb.me/JSXTransformer-0.8.0.js"></script>
-->
<script src="js/lib/es5-shim.js"></script>
<script src="js/lib/es5-sham.js"></script>
<script src="js/lib/react.js"></script>
<script src="js/lib/JSXTransformer.js"></script>
</head>
<body style="font-size: 1.5em">
<h1>Let's React</h1>
<div id="content"></div>
<script type="text/jsx">
/** @jsx React.DOM */
var InputBox = React.createClass({
boom: function(e){
console.log("boom()")
var value = this.refs.mask.getDOMNode().value.trim();
this.refs.mask.getDOMNode().value = "-" + value;
},
render: function(){
return (
<form>
<input type="text" placeholder="Something to mask"
ref="mask" onChange={this.boom} />
</form>
);
}
});
React.renderComponent(
<InputBox />,
document.getElementById('content')
);
</script>
</body>
</html>
@samspot
Copy link
Author

samspot commented Feb 6, 2014

Results in these lines in the console:

E/browser (  285): Console: TypeError: Result of expression 'RegExp.prototype.test.bind' [undefined] is not a function. http://10.0.2.2:8080/react/js/lib/react.js:1714
E/browser (  285): Console: TypeError: Result of expression 'transform.bind' [undefined] is not a function. http://10.0.2.2:8080/react/js/lib/JSXTransformer.js:10195

This was on the android sdk simulator:
device: Nexus 4
Target: Android 2.3.3 (API level 10)

@samspot
Copy link
Author

samspot commented Feb 6, 2014

@johnthethird
Copy link

FYI you should really be doing the JSX transformation either in a build process or on the server. Its not really meant to work that way (using JSX in browser)

@samspot
Copy link
Author

samspot commented Feb 6, 2014

@johnthethird Sure, but this is a proof of concept, not production code.

@samspot
Copy link
Author

samspot commented Feb 6, 2014

Updated with working gist. I'm still having an input issue on android, but that isn't react's fault.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment