mirror of
https://github.com/facebookarchive/prepack.git
synced 2024-10-27 07:41:52 +03:00
afb0a9e9cb
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
26 lines
514 B
JavaScript
26 lines
514 B
JavaScript
var React = require('react');
|
|
// the JSX transform converts to React, so we need to add it back in
|
|
this['React'] = React;
|
|
|
|
function A(props) {
|
|
return <div>{props.children}{props.children}</div>;
|
|
}
|
|
|
|
function App() {
|
|
return (
|
|
<div>
|
|
<A>{['hello']}</A>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
App.getTrials = function(renderer, Root) {
|
|
renderer.update(<Root />);
|
|
return [['render array twice', renderer.toJSON()]];
|
|
};
|
|
|
|
if (this.__optimizeReactComponentTree) {
|
|
__optimizeReactComponentTree(App);
|
|
}
|
|
|
|
module.exports = App; |