Skip to content

Commit

Permalink
Classes consume ref prop during SSR, too (#28731)
Browse files Browse the repository at this point in the history
Same as #28719 but for SSR.

DiffTrain build for [3761acb](3761acb)
  • Loading branch information
acdlite committed Apr 3, 2024
1 parent 6cdcf5b commit a491103
Show file tree
Hide file tree
Showing 7 changed files with 234 additions and 142 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7a2609eedc571049a3272e60d5f7d84601ffca3f
3761acb42bf9979314fff130d4d9505408bcb651
34 changes: 30 additions & 4 deletions compiled/facebook-www/ReactDOMServer-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (__DEV__) {
var React = require("react");
var ReactDOM = require("react-dom");

var ReactVersion = "19.0.0-www-classic-57497d22";
var ReactVersion = "19.0.0-www-classic-81cf15cb";

// This refers to a WWW module.
var warningWWW = require("warning");
Expand Down Expand Up @@ -11996,13 +11996,39 @@ if (__DEV__) {
task.keyPath = prevKeyPath;
}

function resolveClassComponentProps(Component, baseProps) {
var newProps = baseProps; // TODO: This is where defaultProps should be resolved, too.

if (enableRefAsProp) {
// Remove ref from the props object, if it exists.
if ("ref" in newProps) {
newProps = assign({}, newProps);
delete newProps.ref;
}
}

return newProps;
}

function renderClassComponent(request, task, keyPath, Component, props) {
var resolvedProps = resolveClassComponentProps(Component, props);
var previousComponentStack = task.componentStack;
task.componentStack = createClassComponentStack(task, Component);
var maskedContext = getMaskedContext(Component, task.legacyContext);
var instance = constructClassInstance(Component, props, maskedContext);
mountClassInstance(instance, Component, props, maskedContext);
finishClassComponent(request, task, keyPath, instance, Component, props);
var instance = constructClassInstance(
Component,
resolvedProps,
maskedContext
);
mountClassInstance(instance, Component, resolvedProps, maskedContext);
finishClassComponent(
request,
task,
keyPath,
instance,
Component,
resolvedProps
);
task.componentStack = previousComponentStack;
}

Expand Down
30 changes: 26 additions & 4 deletions compiled/facebook-www/ReactDOMServer-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (__DEV__) {
var React = require("react");
var ReactDOM = require("react-dom");

var ReactVersion = "19.0.0-www-modern-e7a96154";
var ReactVersion = "19.0.0-www-modern-e2470d87";

// This refers to a WWW module.
var warningWWW = require("warning");
Expand Down Expand Up @@ -11899,13 +11899,35 @@ if (__DEV__) {
task.keyPath = prevKeyPath;
}

function resolveClassComponentProps(Component, baseProps) {
var newProps = baseProps; // TODO: This is where defaultProps should be resolved, too.

if (enableRefAsProp) {
// Remove ref from the props object, if it exists.
if ("ref" in newProps) {
newProps = assign({}, newProps);
delete newProps.ref;
}
}

return newProps;
}

function renderClassComponent(request, task, keyPath, Component, props) {
var resolvedProps = resolveClassComponentProps(Component, props);
var previousComponentStack = task.componentStack;
task.componentStack = createClassComponentStack(task, Component);
var maskedContext = undefined;
var instance = constructClassInstance(Component, props);
mountClassInstance(instance, Component, props, maskedContext);
finishClassComponent(request, task, keyPath, instance, Component, props);
var instance = constructClassInstance(Component, resolvedProps);
mountClassInstance(instance, Component, resolvedProps, maskedContext);
finishClassComponent(
request,
task,
keyPath,
instance,
Component,
resolvedProps
);
task.componentStack = previousComponentStack;
}

Expand Down
Loading

0 comments on commit a491103

Please sign in to comment.