MCPcopy
hub / github.com/facebook/react / renderViewTransition

Function renderViewTransition

packages/react-server/src/ReactFizzServer.js:2852–2896  ·  view source on GitHub ↗
(
  request: Request,
  task: Task,
  keyPath: KeyNode,
  props: ViewTransitionProps,
)

Source from the content-addressed store, hash-verified

2850}
2851
2852function renderViewTransition(
2853 request: Request,
2854 task: Task,
2855 keyPath: KeyNode,
2856 props: ViewTransitionProps,
2857) {
2858 const prevContext = task.formatContext;
2859 const prevKeyPath = task.keyPath;
2860 // Get the name off props or generate an auto-generated one in case we need it.
2861 const autoName = getViewTransitionName(
2862 props,
2863 task.treeContext,
2864 request.resumableState,
2865 );
2866 task.formatContext = getViewTransitionFormatContext(
2867 request.resumableState,
2868 prevContext,
2869 getViewTransitionClassName(props.default, props.update),
2870 getViewTransitionClassName(props.default, props.enter),
2871 getViewTransitionClassName(props.default, props.exit),
2872 getViewTransitionClassName(props.default, props.share),
2873 props.name,
2874 autoName,
2875 );
2876 task.keyPath = keyPath;
2877 if (props.name != null && props.name !== 'auto') {
2878 renderNodeDestructive(request, task, props.children, -1);
2879 } else {
2880 // This will be auto-assigned a name which claims a "useId" slot.
2881 // This component materialized an id. We treat this as its own level, with
2882 // a single "child" slot.
2883 const prevTreeContext = task.treeContext;
2884 const totalChildren = 1;
2885 const index = 0;
2886 // Modify the id context. Because we'll need to reset this if something
2887 // suspends or errors, we'll use the non-destructive render path.
2888 task.treeContext = pushTreeContext(prevTreeContext, totalChildren, index);
2889 renderNode(request, task, props.children, -1);
2890 // Like the other contexts, this does not need to be in a finally block
2891 // because renderNode takes care of unwinding the stack.
2892 task.treeContext = prevTreeContext;
2893 }
2894 task.formatContext = prevContext;
2895 task.keyPath = prevKeyPath;
2896}
2897
2898function renderElement(
2899 request: Request,

Callers 1

renderElementFunction · 0.85

Calls 6

getViewTransitionNameFunction · 0.90
pushTreeContextFunction · 0.90
renderNodeDestructiveFunction · 0.85
renderNodeFunction · 0.85

Tested by

no test coverage detected