Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass ref as normal prop #28348

Merged
merged 4 commits into from
Feb 20, 2024
Merged

Pass ref as normal prop #28348

merged 4 commits into from
Feb 20, 2024

Conversation

acdlite
Copy link
Collaborator

@acdlite acdlite commented Feb 15, 2024

Depends on:


Changes the behavior of the JSX runtime to pass through ref as a normal prop, rather than plucking it from the props object and storing on the element.

This is a breaking change since it changes the type of the receiving component. However, most code is unaffected since it's unlikely that a component would have attempted to access a ref prop, since it was not possible to get a reference to one.

forwardRef will still pluck ref from the props object, though, since it's extremely common for users to spread the props object onto the inner component and pass ref as a differently named prop. This is for maximum compatibility with existing code — the real impact of this change is that forwardRef is no longer required.

Currently, refs are resolved during child reconciliation and stored on the fiber. As a result of this change, we can move ref resolution to happen only much later, and only for components that actually use them. Then we can remove the ref field from the Fiber type. I have not yet done that in this step, though.

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Feb 15, 2024
@acdlite acdlite force-pushed the pass-ref-as-prop branch 3 times, most recently from 20e5daf to 41c6574 Compare February 15, 2024 22:55
@react-sizebot
Copy link

react-sizebot commented Feb 15, 2024

Comparing: a515d75...63c9fde

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js +0.01% 176.85 kB 176.87 kB = 55.14 kB 55.14 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js +0.07% 178.85 kB 178.97 kB +0.09% 55.72 kB 55.77 kB
facebook-www/ReactDOM-prod.classic.js = 591.91 kB 591.94 kB = 104.47 kB 104.47 kB
facebook-www/ReactDOM-prod.modern.js = 575.20 kB 575.23 kB = 101.47 kB 101.48 kB
oss-experimental/react/cjs/react-jsx-runtime.profiling.js +24.50% 4.16 kB 5.18 kB +19.44% 1.87 kB 2.23 kB
oss-experimental/react/cjs/react-jsx-runtime.production.js +24.50% 4.16 kB 5.18 kB +19.44% 1.87 kB 2.23 kB
oss-experimental/react/cjs/react-jsx-runtime.react-server.production.js +24.12% 4.23 kB 5.25 kB +19.20% 1.89 kB 2.25 kB
oss-experimental/react/cjs/react-jsx-dev-runtime.development.js +4.31% 45.62 kB 47.59 kB +5.61% 13.27 kB 14.02 kB
oss-experimental/react/cjs/react-jsx-runtime.development.js +4.20% 46.85 kB 48.82 kB +5.41% 13.62 kB 14.36 kB
oss-experimental/react/cjs/react-jsx-runtime.react-server.development.js +4.19% 46.92 kB 48.89 kB +5.39% 13.65 kB 14.38 kB
oss-experimental/react/cjs/react.react-server.production.js +3.14% 38.71 kB 39.93 kB +4.88% 11.22 kB 11.77 kB
oss-experimental/react/cjs/react.production.js +3.03% 40.11 kB 41.33 kB +4.71% 10.96 kB 11.47 kB
oss-stable-semver/react/cjs/react-jsx-runtime.profiling.js +2.93% 4.16 kB 4.29 kB +2.52% 1.87 kB 1.91 kB
oss-stable/react/cjs/react-jsx-runtime.profiling.js +2.93% 4.16 kB 4.29 kB +2.52% 1.87 kB 1.91 kB
oss-stable-semver/react/cjs/react-jsx-runtime.production.js +2.93% 4.16 kB 4.29 kB +2.52% 1.87 kB 1.91 kB
oss-stable/react/cjs/react-jsx-runtime.production.js +2.93% 4.16 kB 4.29 kB +2.52% 1.87 kB 1.91 kB
oss-stable-semver/react/cjs/react-jsx-runtime.react-server.production.js +2.89% 4.23 kB 4.35 kB +2.55% 1.89 kB 1.93 kB
oss-stable/react/cjs/react-jsx-runtime.react-server.production.js +2.89% 4.23 kB 4.35 kB +2.55% 1.89 kB 1.93 kB
oss-stable-semver/react/cjs/react.react-server.production.js +2.74% 32.59 kB 33.49 kB +4.43% 9.54 kB 9.96 kB
oss-stable/react/cjs/react.react-server.production.js +2.74% 32.62 kB 33.51 kB +4.42% 9.56 kB 9.99 kB
oss-stable-semver/react/cjs/react.production.js +2.39% 37.48 kB 38.37 kB +3.86% 10.29 kB 10.69 kB
oss-stable/react/cjs/react.production.js +2.38% 37.51 kB 38.40 kB +3.81% 10.32 kB 10.72 kB
oss-experimental/react/cjs/react.react-server.development.js +2.36% 86.69 kB 88.73 kB +3.75% 23.77 kB 24.67 kB
oss-experimental/jest-react/cjs/jest-react.development.js +2.09% 4.12 kB 4.20 kB +4.23% 1.44 kB 1.50 kB
oss-experimental/react/cjs/react-jsx-runtime.production.min.js = 0.86 kB 0.84 kB = 0.54 kB 0.54 kB
oss-experimental/react/cjs/react-jsx-runtime.profiling.min.js = 0.86 kB 0.84 kB = 0.54 kB 0.54 kB
oss-experimental/jest-react/cjs/jest-react.production.min.js = 1.46 kB 1.42 kB +0.26% 0.78 kB 0.78 kB
oss-stable-semver/jest-react/cjs/jest-react.production.min.js = 1.46 kB 1.42 kB +0.26% 0.78 kB 0.78 kB
oss-stable/jest-react/cjs/jest-react.production.min.js = 1.46 kB 1.42 kB +0.26% 0.78 kB 0.78 kB
test_utils/ReactAllWarnings.js Deleted 66.90 kB 0.00 kB Deleted 16.40 kB 0.00 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-experimental/react/cjs/react-jsx-runtime.profiling.js +24.50% 4.16 kB 5.18 kB +19.44% 1.87 kB 2.23 kB
oss-experimental/react/cjs/react-jsx-runtime.production.js +24.50% 4.16 kB 5.18 kB +19.44% 1.87 kB 2.23 kB
oss-experimental/react/cjs/react-jsx-runtime.react-server.production.js +24.12% 4.23 kB 5.25 kB +19.20% 1.89 kB 2.25 kB
oss-experimental/react/cjs/react-jsx-dev-runtime.development.js +4.31% 45.62 kB 47.59 kB +5.61% 13.27 kB 14.02 kB
oss-experimental/react/cjs/react-jsx-runtime.development.js +4.20% 46.85 kB 48.82 kB +5.41% 13.62 kB 14.36 kB
oss-experimental/react/cjs/react-jsx-runtime.react-server.development.js +4.19% 46.92 kB 48.89 kB +5.39% 13.65 kB 14.38 kB
oss-experimental/react/cjs/react.react-server.production.js +3.14% 38.71 kB 39.93 kB +4.88% 11.22 kB 11.77 kB
oss-experimental/react/cjs/react.production.js +3.03% 40.11 kB 41.33 kB +4.71% 10.96 kB 11.47 kB
oss-stable-semver/react/cjs/react-jsx-runtime.profiling.js +2.93% 4.16 kB 4.29 kB +2.52% 1.87 kB 1.91 kB
oss-stable/react/cjs/react-jsx-runtime.profiling.js +2.93% 4.16 kB 4.29 kB +2.52% 1.87 kB 1.91 kB
oss-stable-semver/react/cjs/react-jsx-runtime.production.js +2.93% 4.16 kB 4.29 kB +2.52% 1.87 kB 1.91 kB
oss-stable/react/cjs/react-jsx-runtime.production.js +2.93% 4.16 kB 4.29 kB +2.52% 1.87 kB 1.91 kB
oss-stable-semver/react/cjs/react-jsx-runtime.react-server.production.js +2.89% 4.23 kB 4.35 kB +2.55% 1.89 kB 1.93 kB
oss-stable/react/cjs/react-jsx-runtime.react-server.production.js +2.89% 4.23 kB 4.35 kB +2.55% 1.89 kB 1.93 kB
oss-stable-semver/react/cjs/react.react-server.production.js +2.74% 32.59 kB 33.49 kB +4.43% 9.54 kB 9.96 kB
oss-stable/react/cjs/react.react-server.production.js +2.74% 32.62 kB 33.51 kB +4.42% 9.56 kB 9.99 kB
oss-stable-semver/react/cjs/react.production.js +2.39% 37.48 kB 38.37 kB +3.86% 10.29 kB 10.69 kB
oss-stable/react/cjs/react.production.js +2.38% 37.51 kB 38.40 kB +3.81% 10.32 kB 10.72 kB
oss-experimental/react/cjs/react.react-server.development.js +2.36% 86.69 kB 88.73 kB +3.75% 23.77 kB 24.67 kB
oss-experimental/jest-react/cjs/jest-react.development.js +2.09% 4.12 kB 4.20 kB +4.23% 1.44 kB 1.50 kB
oss-experimental/react/cjs/react.development.js +1.94% 105.51 kB 107.55 kB +3.23% 28.05 kB 28.96 kB
oss-experimental/react/umd/react.development.js +1.65% 128.78 kB 130.90 kB +2.82% 32.78 kB 33.71 kB
oss-stable-semver/react/cjs/react.react-server.development.js +1.14% 80.23 kB 81.15 kB +1.95% 21.91 kB 22.33 kB
oss-stable/react/cjs/react.react-server.development.js +1.14% 80.26 kB 81.17 kB +1.95% 21.93 kB 22.36 kB
oss-stable-semver/react/cjs/react.development.js +0.89% 102.95 kB 103.86 kB +1.62% 27.38 kB 27.82 kB
oss-stable/react/cjs/react.development.js +0.89% 102.97 kB 103.89 kB +1.61% 27.41 kB 27.85 kB
oss-stable-semver/react/umd/react.development.js +0.77% 126.11 kB 127.07 kB +1.42% 32.09 kB 32.55 kB
oss-stable/react/umd/react.development.js +0.77% 126.13 kB 127.10 kB +1.40% 32.13 kB 32.58 kB
oss-experimental/react-server/cjs/react-server-flight.production.js +0.76% 67.65 kB 68.16 kB +1.21% 16.17 kB 16.37 kB
facebook-react-native/react/cjs/JSXDEVRuntime-dev.js +0.76% 39.74 kB 40.04 kB +0.97% 10.41 kB 10.52 kB
facebook-react-native/react/cjs/JSXRuntime-dev.js +0.73% 41.15 kB 41.45 kB +1.00% 10.80 kB 10.91 kB
facebook-www/ReactServer-dev.modern.js +0.62% 96.79 kB 97.39 kB +1.66% 22.63 kB 23.01 kB
oss-experimental/react-server/cjs/react-server-flight.development.js +0.58% 80.78 kB 81.25 kB +0.90% 18.93 kB 19.10 kB
facebook-www/JSXDEVRuntime-dev.modern.js +0.56% 53.49 kB 53.79 kB +0.78% 13.80 kB 13.91 kB
facebook-www/JSXDEVRuntime-dev.classic.js +0.56% 53.49 kB 53.79 kB +0.78% 13.80 kB 13.91 kB
oss-experimental/react-server/cjs/react-server.production.js +0.53% 167.45 kB 168.34 kB +0.72% 38.62 kB 38.90 kB
facebook-react-native/react/cjs/React-dev.js +0.52% 114.36 kB 114.96 kB +1.44% 26.94 kB 27.32 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-server.node.production.js +0.51% 101.37 kB 101.88 kB +0.85% 23.76 kB 23.96 kB
oss-stable-semver/react/cjs/react-jsx-dev-runtime.development.js +0.50% 45.65 kB 45.88 kB +0.56% 13.28 kB 13.35 kB
oss-stable/react/cjs/react-jsx-dev-runtime.development.js +0.50% 45.65 kB 45.88 kB +0.56% 13.28 kB 13.35 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.browser.production.js +0.49% 104.62 kB 105.14 kB +0.80% 24.94 kB 25.14 kB
oss-stable-semver/react/cjs/react-jsx-runtime.development.js +0.49% 46.88 kB 47.11 kB +0.56% 13.63 kB 13.71 kB
oss-stable/react/cjs/react-jsx-runtime.development.js +0.49% 46.88 kB 47.11 kB +0.56% 13.63 kB 13.71 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.production.js +0.49% 105.28 kB 105.80 kB +0.79% 25.17 kB 25.36 kB
oss-stable-semver/react/cjs/react-jsx-runtime.react-server.development.js +0.49% 46.94 kB 47.17 kB +0.55% 13.65 kB 13.73 kB
oss-stable/react/cjs/react-jsx-runtime.react-server.development.js +0.49% 46.94 kB 47.17 kB +0.55% 13.65 kB 13.73 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.production.js +0.48% 106.87 kB 107.39 kB +0.77% 25.55 kB 25.75 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.js +0.48% 107.01 kB 107.52 kB +0.77% 25.61 kB 25.81 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.unbundled.production.js +0.48% 107.51 kB 108.03 kB +0.78% 25.16 kB 25.35 kB
facebook-www/React-dev.modern.js +0.47% 127.08 kB 127.68 kB +1.29% 29.95 kB 30.34 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.production.js +0.47% 109.59 kB 110.10 kB +0.76% 25.65 kB 25.85 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.production.js +0.47% 110.17 kB 110.69 kB +0.76% 25.99 kB 26.19 kB
facebook-www/React-dev.classic.js +0.47% 128.66 kB 129.26 kB +1.36% 30.39 kB 30.80 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.js +0.46% 112.25 kB 112.76 kB +0.75% 26.55 kB 26.75 kB
oss-stable-semver/react-server/cjs/react-server-flight.production.js +0.45% 57.97 kB 58.23 kB +0.73% 14.19 kB 14.30 kB
oss-stable/react-server/cjs/react-server-flight.production.js +0.45% 57.97 kB 58.23 kB +0.73% 14.19 kB 14.30 kB
oss-experimental/react-server/cjs/react-server.development.js +0.42% 212.39 kB 213.28 kB +0.59% 49.10 kB 49.39 kB
oss-experimental/react-server-dom-esm/cjs/react-server-dom-esm-server.node.development.js +0.40% 115.96 kB 116.43 kB +0.63% 27.02 kB 27.19 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.browser.development.js +0.39% 118.78 kB 119.25 kB +0.61% 28.02 kB 28.19 kB
oss-experimental/react-server-dom-turbopack/umd/react-server-dom-turbopack-server.browser.development.js +0.39% 125.25 kB 125.75 kB +0.59% 28.33 kB 28.50 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.development.js +0.39% 120.15 kB 120.62 kB +0.61% 28.44 kB 28.61 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.development.js +0.39% 121.22 kB 121.69 kB +0.60% 28.69 kB 28.86 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +0.38% 122.08 kB 122.55 kB +0.60% 28.94 kB 29.11 kB
oss-experimental/react-server-dom-webpack/umd/react-server-dom-webpack-server.browser.development.js +0.38% 127.82 kB 128.32 kB +0.58% 28.99 kB 29.15 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.unbundled.development.js +0.38% 122.11 kB 122.58 kB +0.65% 28.42 kB 28.61 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +0.38% 124.40 kB 124.87 kB +0.64% 28.99 kB 29.18 kB
oss-experimental/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.development.js +0.38% 124.76 kB 125.22 kB +0.59% 29.27 kB 29.45 kB
oss-experimental/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +0.37% 127.04 kB 127.51 kB +0.66% 29.89 kB 30.09 kB
oss-stable-semver/react-server/cjs/react-server-flight.development.js +0.30% 71.09 kB 71.30 kB +0.57% 16.96 kB 17.05 kB
oss-stable/react-server/cjs/react-server-flight.development.js +0.30% 71.09 kB 71.30 kB +0.57% 16.96 kB 17.05 kB
oss-experimental/react-dom/cjs/react-dom-server.bun.production.js +0.29% 331.27 kB 332.23 kB +0.42% 71.55 kB 71.84 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.browser.production.js +0.29% 332.98 kB 333.94 kB +0.41% 72.01 kB 72.31 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-server.node.production.js +0.28% 91.46 kB 91.72 kB +0.46% 21.72 kB 21.82 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-server.node.production.js +0.28% 91.46 kB 91.72 kB +0.46% 21.72 kB 21.82 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.node.production.js +0.28% 339.21 kB 340.17 kB +0.39% 73.89 kB 74.18 kB
oss-experimental/react-dom/cjs/react-dom-server.browser.production.js +0.28% 341.78 kB 342.73 kB +0.40% 73.11 kB 73.40 kB
oss-experimental/react-dom/cjs/react-dom-server.node.production.js +0.28% 344.18 kB 345.14 kB +0.38% 73.56 kB 73.84 kB
oss-experimental/react-dom/cjs/react-dom-server.edge.production.js +0.28% 346.34 kB 347.30 kB +0.38% 74.56 kB 74.84 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.browser.production.js +0.27% 94.27 kB 94.53 kB +0.47% 22.72 kB 22.83 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.browser.production.js +0.27% 94.27 kB 94.53 kB +0.47% 22.72 kB 22.83 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.production.js +0.27% 94.93 kB 95.19 kB +0.43% 22.95 kB 23.05 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.production.js +0.27% 94.93 kB 95.19 kB +0.43% 22.95 kB 23.05 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.production.js +0.27% 96.52 kB 96.78 kB +0.45% 23.33 kB 23.43 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.browser.production.js +0.27% 96.52 kB 96.78 kB +0.45% 23.33 kB 23.43 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.js +0.27% 96.66 kB 96.91 kB +0.42% 23.38 kB 23.48 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.js +0.27% 96.66 kB 96.91 kB +0.42% 23.38 kB 23.48 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.unbundled.production.js +0.27% 97.61 kB 97.87 kB +0.44% 23.12 kB 23.22 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.unbundled.production.js +0.27% 97.61 kB 97.87 kB +0.44% 23.12 kB 23.22 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.production.js +0.26% 99.69 kB 99.95 kB +0.42% 23.62 kB 23.72 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.production.js +0.26% 99.69 kB 99.95 kB +0.42% 23.62 kB 23.72 kB
facebook-www/ReactFlightDOMServer-dev.modern.js +0.26% 89.49 kB 89.72 kB +0.38% 19.02 kB 19.09 kB
oss-stable-semver/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.production.js +0.26% 100.27 kB 100.53 kB +0.40% 23.95 kB 24.05 kB
oss-stable/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.production.js +0.26% 100.27 kB 100.53 kB +0.40% 23.95 kB 24.05 kB
oss-stable-semver/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.js +0.25% 102.34 kB 102.60 kB +0.43% 24.50 kB 24.60 kB
oss-stable/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.js +0.25% 102.34 kB 102.60 kB +0.43% 24.50 kB 24.60 kB
oss-experimental/react-dom/cjs/react-dom-server.bun.development.js +0.23% 431.03 kB 432.00 kB +0.32% 95.67 kB 95.98 kB
oss-experimental/react-dom/umd/react-dom-server-legacy.browser.development.js +0.23% 457.75 kB 458.78 kB +0.31% 98.55 kB 98.85 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.browser.development.js +0.22% 437.33 kB 438.30 kB +0.31% 97.58 kB 97.88 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.node.development.js +0.22% 439.18 kB 440.16 kB +0.31% 98.05 kB 98.35 kB
oss-experimental/react-dom/umd/react-dom-server.browser.development.js +0.22% 467.02 kB 468.06 kB +0.30% 99.73 kB 100.03 kB
oss-experimental/react-dom/cjs/react-dom-server.node.development.js +0.22% 444.63 kB 445.61 kB +0.32% 97.95 kB 98.27 kB
oss-experimental/react-dom/cjs/react-dom-server.browser.development.js +0.22% 446.20 kB 447.18 kB +0.30% 98.76 kB 99.05 kB
oss-experimental/react-dom/cjs/react-dom-server.edge.development.js +0.22% 446.79 kB 447.76 kB +0.30% 98.89 kB 99.19 kB
oss-experimental/react-server/cjs/react-server.production.min.js +0.22% 41.33 kB 41.42 kB +0.35% 13.00 kB 13.04 kB
oss-stable-semver/react-server-dom-esm/cjs/react-server-dom-esm-server.node.development.js +0.20% 105.38 kB 105.60 kB +0.36% 24.75 kB 24.84 kB
oss-stable/react-server-dom-esm/cjs/react-server-dom-esm-server.node.development.js +0.20% 105.38 kB 105.60 kB +0.36% 24.75 kB 24.84 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer-persistent.development.js = 42.17 kB 42.06 kB +0.20% 9.55 kB 9.57 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer-persistent.development.js = 42.17 kB 42.06 kB +0.20% 9.55 kB 9.57 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer.development.js = 42.04 kB 41.93 kB +0.19% 9.54 kB 9.56 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer.development.js = 42.04 kB 41.93 kB +0.19% 9.54 kB 9.56 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer-persistent.production.js = 36.14 kB 36.01 kB +0.32% 7.61 kB 7.63 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer-persistent.production.js = 36.14 kB 36.01 kB +0.32% 7.61 kB 7.63 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer-persistent.production.js = 36.14 kB 36.01 kB +0.32% 7.61 kB 7.63 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer.production.js = 36.01 kB 35.88 kB +0.30% 7.59 kB 7.61 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer.production.js = 36.01 kB 35.88 kB +0.30% 7.59 kB 7.61 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer.production.js = 36.01 kB 35.88 kB +0.30% 7.59 kB 7.61 kB
oss-stable-semver/jest-react/cjs/jest-react.development.js = 4.12 kB 4.10 kB +1.18% 1.44 kB 1.46 kB
oss-stable/jest-react/cjs/jest-react.development.js = 4.12 kB 4.10 kB +1.18% 1.44 kB 1.46 kB
oss-experimental/jest-react/cjs/jest-react.production.js = 4.03 kB 4.01 kB +1.07% 1.41 kB 1.42 kB
oss-stable-semver/jest-react/cjs/jest-react.production.js = 4.03 kB 4.01 kB +1.07% 1.41 kB 1.42 kB
oss-stable/jest-react/cjs/jest-react.production.js = 4.03 kB 4.01 kB +1.07% 1.41 kB 1.42 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer-persistent.production.min.js = 15.55 kB 15.45 kB +0.19% 4.68 kB 4.69 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer-persistent.production.min.js = 15.55 kB 15.45 kB +0.19% 4.68 kB 4.69 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer-persistent.production.min.js = 15.55 kB 15.45 kB +0.19% 4.68 kB 4.69 kB
oss-experimental/react-noop-renderer/cjs/react-noop-renderer.production.min.js = 15.47 kB 15.37 kB +0.19% 4.67 kB 4.68 kB
oss-stable-semver/react-noop-renderer/cjs/react-noop-renderer.production.min.js = 15.47 kB 15.37 kB +0.19% 4.67 kB 4.68 kB
oss-stable/react-noop-renderer/cjs/react-noop-renderer.production.min.js = 15.47 kB 15.37 kB +0.19% 4.67 kB 4.68 kB
oss-experimental/react/cjs/react-jsx-runtime.react-server.production.min.js = 0.91 kB 0.89 kB = 0.56 kB 0.56 kB
oss-experimental/react/cjs/react-jsx-runtime.production.min.js = 0.86 kB 0.84 kB = 0.54 kB 0.54 kB
oss-experimental/react/cjs/react-jsx-runtime.profiling.min.js = 0.86 kB 0.84 kB = 0.54 kB 0.54 kB
oss-experimental/jest-react/cjs/jest-react.production.min.js = 1.46 kB 1.42 kB +0.26% 0.78 kB 0.78 kB
oss-stable-semver/jest-react/cjs/jest-react.production.min.js = 1.46 kB 1.42 kB +0.26% 0.78 kB 0.78 kB
oss-stable/jest-react/cjs/jest-react.production.min.js = 1.46 kB 1.42 kB +0.26% 0.78 kB 0.78 kB
test_utils/ReactAllWarnings.js Deleted 66.90 kB 0.00 kB Deleted 16.40 kB 0.00 kB

Generated by 🚫 dangerJS against 63c9fde

@acdlite acdlite force-pushed the pass-ref-as-prop branch 11 times, most recently from 9f74cab to 856f9ab Compare February 16, 2024 20:35
@acdlite acdlite marked this pull request as ready for review February 16, 2024 20:35
@acdlite acdlite force-pushed the pass-ref-as-prop branch 3 times, most recently from bd1b316 to 6652d50 Compare February 17, 2024 19:19
// flag is removed, we should get the ref off the props object right
// before using it.
const refProp = props.ref;
ref = refProp !== undefined ? refProp : null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing it along here mostly exists for parity with Fizz in terms of file structure. It'll just error lower. We can probably just pass null here and disable the error.

@@ -698,6 +699,8 @@ function renderElement(
// When the ref moves to the regular props object this will implicitly
// throw for functions. We could probably relax it to a DEV warning for other
// cases.
// TODO: `ref` is now just a prop when `enableRefAsProp` is on. Should we
// do what the above comment says?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should really disable the error here when the flag is on and instead error inside the host component path instead, where it can check props.ref when the flag is on. Class components already error anyway.

When a "ref" prop is passed with a function to a client component it'll just be a general error but we could special case that message similar to how special cased function passed to children here:

#28367

props,
_owner: null,
}: any);
Object.defineProperty(element, 'ref', {
Copy link
Collaborator

@sebmarkbage sebmarkbage Feb 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it helps but it might be worth keeping these as getters that return null so that the object have the same shape whether it's from Flight or JSX.

);
}
}
return ref;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of closure per element it might be worth having a hoisted getter that returns this.props.ref.

return ReactElement(
oldElement.type,
newKey,
oldElement.ref,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good thing you caught this with the warning.

Copy link
Collaborator

@sebmarkbage sebmarkbage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments on minor things.

There's a ton of overlap between the createElement implementation and
the JSX implementation, so I combined them into a single module.

In the actual build output, the shared code between JSX and
createElement will get duplicated anyway, because react/jsx-runtime and
react (where createElement livs) are separate, flat build artifacts.

So this is more about code organization — with a few key exceptions,
the implementations of createElement and jsx are highly coupled.
Adding a flag for this so it can be rolled out incrementally at Meta.
Changes the behavior of the JSX runtime to pass through `ref` as a
normal prop, rather than plucking it from the props object and storing
on the element.

This is a breaking change since it changes the type receiving component.
However, most code is unaffected since it's unlikely that a component
would have attempted to access a `ref` prop, since it was not possible
to get a reference to one.

`forwardRef` _will_ still pluck `ref` from the props object, though,
since it's extremely common for users to spread the props object onto
the inner component and pass `ref` as a differently named prop. This is
for maximum compatibility with existing code — the real impact of this
change is that `forwardRef` is no longer required.

Currently, refs are resolved during child reconciliation and stored on
the fiber. As a result of this change, we can move ref resolution to
happen only much later, and only for components that actually use them.
Then we can remove the `ref` field from the Fiber type. I have not yet
done that in this step, though.
In the last commit I removed the `ref` property from the element type
completely. Instead, let's keep it for another release cycle but warn
if it's accessed.

In dev, we add a non-enumerable getter with `defineProperty` and warn
whenever it's invoked.

We don't warn on access if a ref is not given. This reduces false
positives in cases where a test serializer uses
`getOwnPropertyDescriptors`` to compare objects, like Jest does, which
is a problem because it bypasses non-enumerability.

So unfortunately this will trigger a false positive warning in Jest when
the diff is printed:

  expect(<div ref={ref} />).toEqual(<span ref={ref} />);

A bit sketchy, but this is what we've done for the `props.key` and
`props.ref` accessors for years, which implies it will be good enough
for `element.ref`, too. Let's see if anyone complains.
@acdlite acdlite merged commit fa2f82a into facebook:main Feb 20, 2024
36 checks passed
github-actions bot pushed a commit that referenced this pull request Feb 20, 2024
Depends on:

- #28317
- #28320

---

Changes the behavior of the JSX runtime to pass through `ref` as a
normal prop, rather than plucking it from the props object and storing
on the element.

This is a breaking change since it changes the type of the receiving
component. However, most code is unaffected since it's unlikely that a
component would have attempted to access a `ref` prop, since it was not
possible to get a reference to one.

`forwardRef` _will_ still pluck `ref` from the props object, though,
since it's extremely common for users to spread the props object onto
the inner component and pass `ref` as a differently named prop. This is
for maximum compatibility with existing code — the real impact of this
change is that `forwardRef` is no longer required.

Currently, refs are resolved during child reconciliation and stored on
the fiber. As a result of this change, we can move ref resolution to
happen only much later, and only for components that actually use them.
Then we can remove the `ref` field from the Fiber type. I have not yet
done that in this step, though.

DiffTrain build for [fa2f82a](fa2f82a)
@nstepien
Copy link

Currently we have code like this

const element = Children.only(children);
const combinedRef = useCombinedRefs(ref, element.ref);
const clonedElement = cloneElement(element, { ref: combinedRef });

Will we need to change element.ref to element.props.ref?

@nihgwu
Copy link
Contributor

nihgwu commented Feb 20, 2024

@nstepien it will still work for now https://github.com/facebook/react/pull/28348/files#diff-dbd72a473871eeddbe00ceed54a59bff33e6324ffdea15cb4ee3abbdad988cfbR250

hoxyq added a commit that referenced this pull request Feb 22, 2024
Full list of changes (not a public CHANGELOG):

* feature[REMOVED][devtools]: turn off / hide location based component
filters ([hoxyq](https://github.com/hoxyq) in
[#28417](#28417))
* Add useSyncExternalStore and useTransition to getPrimitiveStackCache
([jamesbvaughan](https://github.com/jamesbvaughan) in
[#28399](#28399))
* chore[devtools]: use react-window from npm and bump
react-virtualized-auto-sizer to ^1.0.23
([hoxyq](https://github.com/hoxyq) in
[#28408](#28408))
* Pass ref as normal prop ([acdlite](https://github.com/acdlite) in
[#28348](#28348))
* Combine createElement and JSX modules
([acdlite](https://github.com/acdlite) in
[#28320](#28320))
* [Debug Tools] Always use includeHooksSource option
([sebmarkbage](https://github.com/sebmarkbage) in
[#28309](#28309))
* Revert "[Tests] Reset modules by default"
([acdlite](https://github.com/acdlite) in
[#28318](#28318))
* Switch <Context> to mean <Context.Provider>
([gaearon](https://github.com/gaearon) in
[#28226](#28226))
* [Debug Tools] Introspect Promises in use()
([sebmarkbage](https://github.com/sebmarkbage) in
[#28297](#28297))
* fix[devtools/useModalDismissSignal]: use getRootNode for shadow root
case support ([hoxyq](https://github.com/hoxyq) in
[#28145](#28145))
* fix: define IS_ACT_ENVIRONMENT global for tests with concurrent mode
and synchronous act ([hoxyq](https://github.com/hoxyq) in
[#28296](#28296))
* chore: gate legacy apis for react-devtools-shell
([hoxyq](https://github.com/hoxyq) in
[#28273](#28273))
* DevTools: Add support for use(Context)
([eps1lon](https://github.com/eps1lon) in
[#28233](#28233))
* Remove __self and __source location from elements
([sebmarkbage](https://github.com/sebmarkbage) in
[#28265](#28265))
* chore: use versioned render in inspectedElement test
([hoxyq](https://github.com/hoxyq) in
[#28246](#28246))
* chore: use versioned render in TimelineProfiler test and gate some for
legacy rendering ([hoxyq](https://github.com/hoxyq) in
[#28218](#28218))
* [Tests] Reset modules by default
([rickhanlonii](https://github.com/rickhanlonii) in
[#28254](#28254))
* chore: use versioned render in preprocessData test and gate some for …
([hoxyq](https://github.com/hoxyq) in
[#28219](#28219))
* chore: use versioned render in storeStressSync test and gate them for
legacy rendering ([hoxyq](https://github.com/hoxyq) in
[#28216](#28216))
* Patch devtools before running useMemo function in strict mode
([gsathya](https://github.com/gsathya) in
[#28249](#28249))
* chore: use versioned render in storeComponentFilters test
([hoxyq](https://github.com/hoxyq) in
[#28241](#28241))
* chore: use versioned render in profilerContext test
([hoxyq](https://github.com/hoxyq) in
[#28243](#28243))
* chore: use versioned render in profilingCommitTreeBuilder test and
gate some for legacy rendering ([hoxyq](https://github.com/hoxyq) in
[#28236](#28236))
* chore: use versioned render in profilingHostRoot test and gate some
for legacy rendering ([hoxyq](https://github.com/hoxyq) in
[#28237](#28237))
* chore: use versioned render in profilingCache test
([hoxyq](https://github.com/hoxyq) in
[#28242](#28242))
* chore: use versioned render in ownersListContext test
([hoxyq](https://github.com/hoxyq) in
[#28240](#28240))
* chore: use versioned render in editing test
([hoxyq](https://github.com/hoxyq) in
[#28239](#28239))
* chore: use versioned render in treeContext test
([hoxyq](https://github.com/hoxyq) in
[#28245](#28245))
* chore: use versioned render in store test
([hoxyq](https://github.com/hoxyq) in
[#28244](#28244))
* chore: use versioned render in profilerStore test
([hoxyq](https://github.com/hoxyq) in
[#28238](#28238))
* chore: use versioned render in profilingCharts test
([hoxyq](https://github.com/hoxyq) in
[#28235](#28235))
* chore: use versioned render in profilerChangeDescriptions test
([hoxyq](https://github.com/hoxyq) in
[#28221](#28221))
* chore: use versioned render in storeOwners test
([hoxyq](https://github.com/hoxyq) in
[#28215](#28215))
* chore: use versioned render in componentStacks test
([hoxyq](https://github.com/hoxyq) in
[#28214](#28214))
* chore: use versioned render in console test
([hoxyq](https://github.com/hoxyq) in
[#28213](#28213))
* chore: use versioned render in useEditableValue test
([hoxyq](https://github.com/hoxyq) in
[#28212](#28212))
* chore: use versioned render in FastRefreshDevToolsIntegration test
([hoxyq](https://github.com/hoxyq) in
[#28211](#28211))
* chore: add versioned render implementation for DevTools tests
([hoxyq](https://github.com/hoxyq) in
[#28210](#28210))
* chore: add single versioned implementation of act for DevTools tests
([hoxyq](https://github.com/hoxyq) in
[#28186](#28186))
* DevTools: Add support for useFormState
([eps1lon](https://github.com/eps1lon) in
[#28232](#28232))
* DevTools: Add support for useOptimistic Hook
([eps1lon](https://github.com/eps1lon) in
[#27982](#27982))
* Add stable React.act export ([acdlite](https://github.com/acdlite) in
[#28160](#28160))
* [flow] upgrade to 0.225.1 ([kassens](https://github.com/kassens) in
[#27871](#27871))
* fix[devtools/e2e]: add fallback for act in integration tests
([hoxyq](https://github.com/hoxyq) in
[#27842](#27842))
* Add stable concurrent option to react-test-renderer
([jackpope](https://github.com/jackpope) in
[#27804](#27804))
* Update act references in tests ([gnoff](https://github.com/gnoff) in
[#27805](#27805))
* Flow: make more objects exact ([kassens](https://github.com/kassens)
in [#27790](#27790))
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
Depends on:

- facebook#28317 
- facebook#28320 

---

Changes the behavior of the JSX runtime to pass through `ref` as a
normal prop, rather than plucking it from the props object and storing
on the element.

This is a breaking change since it changes the type of the receiving
component. However, most code is unaffected since it's unlikely that a
component would have attempted to access a `ref` prop, since it was not
possible to get a reference to one.

`forwardRef` _will_ still pluck `ref` from the props object, though,
since it's extremely common for users to spread the props object onto
the inner component and pass `ref` as a differently named prop. This is
for maximum compatibility with existing code — the real impact of this
change is that `forwardRef` is no longer required.

Currently, refs are resolved during child reconciliation and stored on
the fiber. As a result of this change, we can move ref resolution to
happen only much later, and only for components that actually use them.
Then we can remove the `ref` field from the Fiber type. I have not yet
done that in this step, though.
EdisonVan pushed a commit to EdisonVan/react that referenced this pull request Apr 15, 2024
Full list of changes (not a public CHANGELOG):

* feature[REMOVED][devtools]: turn off / hide location based component
filters ([hoxyq](https://github.com/hoxyq) in
[facebook#28417](facebook#28417))
* Add useSyncExternalStore and useTransition to getPrimitiveStackCache
([jamesbvaughan](https://github.com/jamesbvaughan) in
[facebook#28399](facebook#28399))
* chore[devtools]: use react-window from npm and bump
react-virtualized-auto-sizer to ^1.0.23
([hoxyq](https://github.com/hoxyq) in
[facebook#28408](facebook#28408))
* Pass ref as normal prop ([acdlite](https://github.com/acdlite) in
[facebook#28348](facebook#28348))
* Combine createElement and JSX modules
([acdlite](https://github.com/acdlite) in
[facebook#28320](facebook#28320))
* [Debug Tools] Always use includeHooksSource option
([sebmarkbage](https://github.com/sebmarkbage) in
[facebook#28309](facebook#28309))
* Revert "[Tests] Reset modules by default"
([acdlite](https://github.com/acdlite) in
[facebook#28318](facebook#28318))
* Switch <Context> to mean <Context.Provider>
([gaearon](https://github.com/gaearon) in
[facebook#28226](facebook#28226))
* [Debug Tools] Introspect Promises in use()
([sebmarkbage](https://github.com/sebmarkbage) in
[facebook#28297](facebook#28297))
* fix[devtools/useModalDismissSignal]: use getRootNode for shadow root
case support ([hoxyq](https://github.com/hoxyq) in
[facebook#28145](facebook#28145))
* fix: define IS_ACT_ENVIRONMENT global for tests with concurrent mode
and synchronous act ([hoxyq](https://github.com/hoxyq) in
[facebook#28296](facebook#28296))
* chore: gate legacy apis for react-devtools-shell
([hoxyq](https://github.com/hoxyq) in
[facebook#28273](facebook#28273))
* DevTools: Add support for use(Context)
([eps1lon](https://github.com/eps1lon) in
[facebook#28233](facebook#28233))
* Remove __self and __source location from elements
([sebmarkbage](https://github.com/sebmarkbage) in
[facebook#28265](facebook#28265))
* chore: use versioned render in inspectedElement test
([hoxyq](https://github.com/hoxyq) in
[facebook#28246](facebook#28246))
* chore: use versioned render in TimelineProfiler test and gate some for
legacy rendering ([hoxyq](https://github.com/hoxyq) in
[facebook#28218](facebook#28218))
* [Tests] Reset modules by default
([rickhanlonii](https://github.com/rickhanlonii) in
[facebook#28254](facebook#28254))
* chore: use versioned render in preprocessData test and gate some for …
([hoxyq](https://github.com/hoxyq) in
[facebook#28219](facebook#28219))
* chore: use versioned render in storeStressSync test and gate them for
legacy rendering ([hoxyq](https://github.com/hoxyq) in
[facebook#28216](facebook#28216))
* Patch devtools before running useMemo function in strict mode
([gsathya](https://github.com/gsathya) in
[facebook#28249](facebook#28249))
* chore: use versioned render in storeComponentFilters test
([hoxyq](https://github.com/hoxyq) in
[facebook#28241](facebook#28241))
* chore: use versioned render in profilerContext test
([hoxyq](https://github.com/hoxyq) in
[facebook#28243](facebook#28243))
* chore: use versioned render in profilingCommitTreeBuilder test and
gate some for legacy rendering ([hoxyq](https://github.com/hoxyq) in
[facebook#28236](facebook#28236))
* chore: use versioned render in profilingHostRoot test and gate some
for legacy rendering ([hoxyq](https://github.com/hoxyq) in
[facebook#28237](facebook#28237))
* chore: use versioned render in profilingCache test
([hoxyq](https://github.com/hoxyq) in
[facebook#28242](facebook#28242))
* chore: use versioned render in ownersListContext test
([hoxyq](https://github.com/hoxyq) in
[facebook#28240](facebook#28240))
* chore: use versioned render in editing test
([hoxyq](https://github.com/hoxyq) in
[facebook#28239](facebook#28239))
* chore: use versioned render in treeContext test
([hoxyq](https://github.com/hoxyq) in
[facebook#28245](facebook#28245))
* chore: use versioned render in store test
([hoxyq](https://github.com/hoxyq) in
[facebook#28244](facebook#28244))
* chore: use versioned render in profilerStore test
([hoxyq](https://github.com/hoxyq) in
[facebook#28238](facebook#28238))
* chore: use versioned render in profilingCharts test
([hoxyq](https://github.com/hoxyq) in
[facebook#28235](facebook#28235))
* chore: use versioned render in profilerChangeDescriptions test
([hoxyq](https://github.com/hoxyq) in
[facebook#28221](facebook#28221))
* chore: use versioned render in storeOwners test
([hoxyq](https://github.com/hoxyq) in
[facebook#28215](facebook#28215))
* chore: use versioned render in componentStacks test
([hoxyq](https://github.com/hoxyq) in
[facebook#28214](facebook#28214))
* chore: use versioned render in console test
([hoxyq](https://github.com/hoxyq) in
[facebook#28213](facebook#28213))
* chore: use versioned render in useEditableValue test
([hoxyq](https://github.com/hoxyq) in
[facebook#28212](facebook#28212))
* chore: use versioned render in FastRefreshDevToolsIntegration test
([hoxyq](https://github.com/hoxyq) in
[facebook#28211](facebook#28211))
* chore: add versioned render implementation for DevTools tests
([hoxyq](https://github.com/hoxyq) in
[facebook#28210](facebook#28210))
* chore: add single versioned implementation of act for DevTools tests
([hoxyq](https://github.com/hoxyq) in
[facebook#28186](facebook#28186))
* DevTools: Add support for useFormState
([eps1lon](https://github.com/eps1lon) in
[facebook#28232](facebook#28232))
* DevTools: Add support for useOptimistic Hook
([eps1lon](https://github.com/eps1lon) in
[facebook#27982](facebook#27982))
* Add stable React.act export ([acdlite](https://github.com/acdlite) in
[facebook#28160](facebook#28160))
* [flow] upgrade to 0.225.1 ([kassens](https://github.com/kassens) in
[facebook#27871](facebook#27871))
* fix[devtools/e2e]: add fallback for act in integration tests
([hoxyq](https://github.com/hoxyq) in
[facebook#27842](facebook#27842))
* Add stable concurrent option to react-test-renderer
([jackpope](https://github.com/jackpope) in
[facebook#27804](facebook#27804))
* Update act references in tests ([gnoff](https://github.com/gnoff) in
[facebook#27805](facebook#27805))
* Flow: make more objects exact ([kassens](https://github.com/kassens)
in [facebook#27790](facebook#27790))
bigfootjon pushed a commit that referenced this pull request Apr 18, 2024
Depends on:

- #28317
- #28320

---

Changes the behavior of the JSX runtime to pass through `ref` as a
normal prop, rather than plucking it from the props object and storing
on the element.

This is a breaking change since it changes the type of the receiving
component. However, most code is unaffected since it's unlikely that a
component would have attempted to access a `ref` prop, since it was not
possible to get a reference to one.

`forwardRef` _will_ still pluck `ref` from the props object, though,
since it's extremely common for users to spread the props object onto
the inner component and pass `ref` as a differently named prop. This is
for maximum compatibility with existing code — the real impact of this
change is that `forwardRef` is no longer required.

Currently, refs are resolved during child reconciliation and stored on
the fiber. As a result of this change, we can move ref resolution to
happen only much later, and only for components that actually use them.
Then we can remove the `ref` field from the Fiber type. I have not yet
done that in this step, though.

DiffTrain build for commit fa2f82a.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants