-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42287 from margelo/feat/react-compiler
[NoQA] feat: react-compiler
- Loading branch information
Showing
10 changed files
with
526 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// lib/react-compiler-runtime.js | ||
const $empty = Symbol.for("react.memo_cache_sentinel"); | ||
const React = require('react'); | ||
/** | ||
* DANGER: this hook is NEVER meant to be called directly! | ||
* | ||
* Note that this is a temporary userspace implementation of this function | ||
* from React 19. It is not as efficient and may invalidate more frequently | ||
* than the official API. Better to upgrade to React 19 as soon as we can. | ||
**/ | ||
export function c(size) { | ||
return React.useState(() => { | ||
const $ = new Array(size); | ||
for (let ii = 0; ii < size; ii++) { | ||
$[ii] = $empty; | ||
} | ||
// @ts-ignore | ||
$[$empty] = true; | ||
return $; | ||
})[0]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "react-compiler-runtime", | ||
"version": "0.0.1", | ||
"description": "Runtime for React Compiler", | ||
"license": "MIT", | ||
"main": "index.js", | ||
"dependencies": { | ||
"react": "^18.2.0" | ||
} | ||
} |
Oops, something went wrong.