prepack/test/react/functional-components/simple-assign.js
Dominic Gannaway afb0a9e9cb Change how to signal React components for optimization
Summary:
Release notes: none

Currently, you register a React component tree with `__registerReactComponent(component)`.

This PR changes this global to `__optimizeReactComponentTree(rootComponent, config)`. Notice it now supports two arguments `rootComponent` and `config` – although config is optional.

This global now also returns the original component passed in, so it can be added to existing codebase without having to break logic flow.

This config argument allows the user to define how that React component tree will be optimized. More work will be added to this in upcoming PRs, but for now this PR is just a quick rename plus small refactor of the Prepack global.

I've also had to rename the global in all tests. I've also added some doc as to how all this works: https://github.com/facebook/prepack/wiki/React-Compiler
Closes https://github.com/facebook/prepack/pull/1527

Differential Revision: D7149728

Pulled By: trueadm

fbshipit-source-id: 8d04d8dec8c0a03a6ccdb9587884bf6375010203
2018-03-04 02:24:49 -08:00

26 lines
505 B
JavaScript

var React = require('react');
this['React'] = React;
function A(props) {
return <div>Hello {props.x}</div>;
}
function App(props) {
var copyOfProps = Object.assign({}, props);
return (
<div>
<A x={copyOfProps.x} />
</div>
);
}
App.getTrials = function(renderer, Root) {
renderer.update(<Root x={10} />);
return [['simple render with object assign', renderer.toJSON()]];
};
if (this.__optimizeReactComponentTree) {
__optimizeReactComponentTree(App);
}
module.exports = App;