prepack/test/react/functional-components/simple-8.js
Dominic Gannaway cd30805c65 Ensure React component write effects do not conflict one another
Summary:
Release notes: none

This PR adds some sanity around React components roots that when render, mutate the same of bindings as other React component roots. This is currently not supported and thus safely bails out and continues.
Closes https://github.com/facebook/prepack/pull/1736

Differential Revision: D7600373

Pulled By: trueadm

fbshipit-source-id: fe2b2b3055fa3c1b28668da6d67bca3826431eb6
2018-04-12 09:55:14 -07:00

33 lines
585 B
JavaScript

var React = require('react');
// the JSX transform converts to React, so we need to add it back in
this['React'] = React;
let lazyVariable = null;
function A(props) {
if (!lazyVariable) {
lazyVariable = 123;
}
return <div>Hello {lazyVariable}</div>;
}
function App() {
return (
<div>
<A />
<A />
<A />
</div>
);
}
App.getTrials = function(renderer, Root) {
renderer.update(<Root />);
return [['simple render', renderer.toJSON()]];
};
if (this.__optimizeReactComponentTree) {
__optimizeReactComponentTree(App);
}
module.exports = App;