Best JavaScript code snippet using playwright-internal
c4d79fd1147e4253241bf36ee99d06de7e27dfReactFiberClassComponent.js
Source:c4d79fd1147e4253241bf36ee99d06de7e27dfReactFiberClassComponent.js
...74 startPhaseTimer(workInProgress, 'shouldComponentUpdate');75 }76 var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, newContext);77 if (__DEV__) {78 stopPhaseTimer();79 }80 if (__DEV__) {81 warning(shouldUpdate !== undefined, '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(workInProgress) || 'Unknown');82 }83 return shouldUpdate;84 }85 var type = workInProgress.type;86 if (type.prototype && type.prototype.isPureReactComponent) {87 return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState);88 }89 return true;90 }91 function checkClassInstance(workInProgress) {92 var instance = workInProgress.stateNode;93 if (__DEV__) {94 var name = getComponentName(workInProgress);95 var renderPresent = instance.render;96 warning(renderPresent, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name);97 var noGetInitialStateOnES6 = !instance.getInitialState || instance.getInitialState.isReactClassApproved || instance.state;98 warning(noGetInitialStateOnES6, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', name);99 var noGetDefaultPropsOnES6 = !instance.getDefaultProps || instance.getDefaultProps.isReactClassApproved;100 warning(noGetDefaultPropsOnES6, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', name);101 var noInstancePropTypes = !instance.propTypes;102 warning(noInstancePropTypes, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name);103 var noInstanceContextTypes = !instance.contextTypes;104 warning(noInstanceContextTypes, 'contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name);105 var noComponentShouldUpdate = typeof instance.componentShouldUpdate !== 'function';106 warning(noComponentShouldUpdate, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', name);107 var noComponentDidUnmount = typeof instance.componentDidUnmount !== 'function';108 warning(noComponentDidUnmount, '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name);109 var noComponentWillRecieveProps = typeof instance.componentWillRecieveProps !== 'function';110 warning(noComponentWillRecieveProps, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name);111 var hasMutatedProps = instance.props !== workInProgress.pendingProps;112 warning(instance.props === undefined || !hasMutatedProps, '%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name);113 }114 var state = instance.state;115 if (state && (typeof state !== 'object' || isArray(state))) {116 invariant(false, '%s.state: must be set to an object or null', getComponentName(workInProgress));117 }118 if (typeof instance.getChildContext === 'function') {119 invariant(typeof workInProgress.type.childContextTypes === 'object', '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', getComponentName(workInProgress));120 }121 }122 function resetInputPointers(workInProgress, instance) {123 instance.props = workInProgress.memoizedProps;124 instance.state = workInProgress.memoizedState;125 }126 function adoptClassInstance(workInProgress, instance) {127 instance.updater = updater;128 workInProgress.stateNode = instance;129 ReactInstanceMap.set(instance, workInProgress);130 }131 function constructClassInstance(workInProgress) {132 var ctor = workInProgress.type;133 var props = workInProgress.pendingProps;134 var unmaskedContext = getUnmaskedContext(workInProgress);135 var needsContext = isContextConsumer(workInProgress);136 var context = needsContext ? getMaskedContext(workInProgress, unmaskedContext) : emptyObject;137 var instance = new ctor(props, context);138 adoptClassInstance(workInProgress, instance);139 checkClassInstance(workInProgress);140 if (needsContext) {141 cacheContext(workInProgress, unmaskedContext, context);142 }143 return instance;144 }145 function mountClassInstance(workInProgress, priorityLevel) {146 var instance = workInProgress.stateNode;147 var state = instance.state || null;148 var props = workInProgress.pendingProps;149 invariant(props, 'There must be pending props for an initial mount. This error is ' + 'likely caused by a bug in React. Please file an issue.');150 var unmaskedContext = getUnmaskedContext(workInProgress);151 instance.props = props;152 instance.state = state;153 instance.refs = emptyObject;154 instance.context = getMaskedContext(workInProgress, unmaskedContext);155 if (typeof instance.componentWillMount === 'function') {156 if (__DEV__) {157 startPhaseTimer(workInProgress, 'componentWillMount');158 }159 instance.componentWillMount();160 if (__DEV__) {161 stopPhaseTimer();162 }163 var updateQueue = workInProgress.updateQueue;164 if (updateQueue !== null) {165 instance.state = beginUpdateQueue(workInProgress, updateQueue, instance, state, props, priorityLevel);166 }167 }168 if (typeof instance.componentDidMount === 'function') {169 workInProgress.effectTag |= Update;170 }171 }172 function resumeMountClassInstance(workInProgress, priorityLevel) {173 var instance = workInProgress.stateNode;174 resetInputPointers(workInProgress, instance);175 var newState = workInProgress.memoizedState;176 var newProps = workInProgress.pendingProps;177 if (!newProps) {178 newProps = workInProgress.memoizedProps;179 invariant(newProps != null, 'There should always be pending or memoized props. This error is ' + 'likely caused by a bug in React. Please file an issue.');180 }181 var newUnmaskedContext = getUnmaskedContext(workInProgress);182 var newContext = getMaskedContext(workInProgress, newUnmaskedContext);183 if (!checkShouldComponentUpdate(workInProgress, workInProgress.memoizedProps, newProps, workInProgress.memoizedState, newState, newContext)) {184 instance.props = newProps;185 instance.state = newState;186 instance.context = newContext;187 return false;188 }189 var newInstance = constructClassInstance(workInProgress);190 newInstance.props = newProps;191 newInstance.state = newState = newInstance.state || null;192 newInstance.context = newContext;193 if (typeof newInstance.componentWillMount === 'function') {194 if (__DEV__) {195 startPhaseTimer(workInProgress, 'componentWillMount');196 }197 newInstance.componentWillMount();198 if (__DEV__) {199 stopPhaseTimer();200 }201 }202 var newUpdateQueue = workInProgress.updateQueue;203 if (newUpdateQueue !== null) {204 newInstance.state = beginUpdateQueue(workInProgress, newUpdateQueue, newInstance, newState, newProps, priorityLevel);205 }206 if (typeof instance.componentDidMount === 'function') {207 workInProgress.effectTag |= Update;208 }209 return true;210 }211 function updateClassInstance(current, workInProgress, priorityLevel) {212 var instance = workInProgress.stateNode;213 resetInputPointers(workInProgress, instance);214 var oldProps = workInProgress.memoizedProps;215 var newProps = workInProgress.pendingProps;216 if (!newProps) {217 newProps = oldProps;218 invariant(newProps != null, 'There should always be pending or memoized props. This error is ' + 'likely caused by a bug in React. Please file an issue.');219 }220 var oldContext = instance.context;221 var newUnmaskedContext = getUnmaskedContext(workInProgress);222 var newContext = getMaskedContext(workInProgress, newUnmaskedContext);223 if (oldProps !== newProps || oldContext !== newContext) {224 if (typeof instance.componentWillReceiveProps === 'function') {225 if (__DEV__) {226 startPhaseTimer(workInProgress, 'componentWillReceiveProps');227 }228 instance.componentWillReceiveProps(newProps, newContext);229 if (__DEV__) {230 stopPhaseTimer();231 }232 if (instance.state !== workInProgress.memoizedState) {233 if (__DEV__) {234 warning(false, '%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentName(workInProgress));235 }236 updater.enqueueReplaceState(instance, instance.state, null);237 }238 }239 }240 var updateQueue = workInProgress.updateQueue;241 var oldState = workInProgress.memoizedState;242 var newState = void 0;243 if (updateQueue !== null) {244 newState = beginUpdateQueue(workInProgress, updateQueue, instance, oldState, newProps, priorityLevel);245 } else {246 newState = oldState;247 }248 if (oldProps === newProps && oldState === newState && !hasContextChanged() && !(updateQueue !== null && updateQueue.hasForceUpdate)) {249 if (typeof instance.componentDidUpdate === 'function') {250 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {251 workInProgress.effectTag |= Update;252 }253 }254 return false;255 }256 var shouldUpdate = checkShouldComponentUpdate(workInProgress, oldProps, newProps, oldState, newState, newContext);257 if (shouldUpdate) {258 if (typeof instance.componentWillUpdate === 'function') {259 if (__DEV__) {260 startPhaseTimer(workInProgress, 'componentWillUpdate');261 }262 instance.componentWillUpdate(newProps, newState, newContext);263 if (__DEV__) {264 stopPhaseTimer();265 }266 }267 if (typeof instance.componentDidUpdate === 'function') {268 workInProgress.effectTag |= Update;269 }270 } else {271 if (typeof instance.componentDidUpdate === 'function') {272 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {273 workInProgress.effectTag |= Update;274 }275 }276 memoizeProps(workInProgress, newProps);277 memoizeState(workInProgress, newState);278 }...
f189e48c57ab153db02a9093b6892b2590ce4dReactFiberClassComponent.js
Source:f189e48c57ab153db02a9093b6892b2590ce4dReactFiberClassComponent.js
...74 startPhaseTimer(workInProgress, 'shouldComponentUpdate');75 }76 var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, newContext);77 if (__DEV__) {78 stopPhaseTimer();79 }80 if (__DEV__) {81 warning(shouldUpdate !== undefined, '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(workInProgress) || 'Unknown');82 }83 return shouldUpdate;84 }85 var type = workInProgress.type;86 if (type.prototype && type.prototype.isPureReactComponent) {87 return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState);88 }89 return true;90 }91 function checkClassInstance(workInProgress) {92 var instance = workInProgress.stateNode;93 if (__DEV__) {94 var name = getComponentName(workInProgress);95 var renderPresent = instance.render;96 warning(renderPresent, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name);97 var noGetInitialStateOnES6 = !instance.getInitialState || instance.getInitialState.isReactClassApproved || instance.state;98 warning(noGetInitialStateOnES6, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', name);99 var noGetDefaultPropsOnES6 = !instance.getDefaultProps || instance.getDefaultProps.isReactClassApproved;100 warning(noGetDefaultPropsOnES6, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', name);101 var noInstancePropTypes = !instance.propTypes;102 warning(noInstancePropTypes, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name);103 var noInstanceContextTypes = !instance.contextTypes;104 warning(noInstanceContextTypes, 'contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name);105 var noComponentShouldUpdate = typeof instance.componentShouldUpdate !== 'function';106 warning(noComponentShouldUpdate, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', name);107 var noComponentDidUnmount = typeof instance.componentDidUnmount !== 'function';108 warning(noComponentDidUnmount, '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name);109 var noComponentWillRecieveProps = typeof instance.componentWillRecieveProps !== 'function';110 warning(noComponentWillRecieveProps, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name);111 var hasMutatedProps = instance.props !== workInProgress.pendingProps;112 warning(instance.props === undefined || !hasMutatedProps, '%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name);113 }114 var state = instance.state;115 if (state && (typeof state !== 'object' || isArray(state))) {116 invariant(false, '%s.state: must be set to an object or null', getComponentName(workInProgress));117 }118 if (typeof instance.getChildContext === 'function') {119 invariant(typeof workInProgress.type.childContextTypes === 'object', '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', getComponentName(workInProgress));120 }121 }122 function resetInputPointers(workInProgress, instance) {123 instance.props = workInProgress.memoizedProps;124 instance.state = workInProgress.memoizedState;125 }126 function adoptClassInstance(workInProgress, instance) {127 instance.updater = updater;128 workInProgress.stateNode = instance;129 ReactInstanceMap.set(instance, workInProgress);130 }131 function constructClassInstance(workInProgress) {132 var ctor = workInProgress.type;133 var props = workInProgress.pendingProps;134 var unmaskedContext = getUnmaskedContext(workInProgress);135 var needsContext = isContextConsumer(workInProgress);136 var context = needsContext ? getMaskedContext(workInProgress, unmaskedContext) : emptyObject;137 var instance = new ctor(props, context);138 adoptClassInstance(workInProgress, instance);139 checkClassInstance(workInProgress);140 if (needsContext) {141 cacheContext(workInProgress, unmaskedContext, context);142 }143 return instance;144 }145 function mountClassInstance(workInProgress, priorityLevel) {146 var instance = workInProgress.stateNode;147 var state = instance.state || null;148 var props = workInProgress.pendingProps;149 invariant(props, 'There must be pending props for an initial mount. This error is ' + 'likely caused by a bug in React. Please file an issue.');150 var unmaskedContext = getUnmaskedContext(workInProgress);151 instance.props = props;152 instance.state = state;153 instance.refs = emptyObject;154 instance.context = getMaskedContext(workInProgress, unmaskedContext);155 if (typeof instance.componentWillMount === 'function') {156 if (__DEV__) {157 startPhaseTimer(workInProgress, 'componentWillMount');158 }159 instance.componentWillMount();160 if (__DEV__) {161 stopPhaseTimer();162 }163 var updateQueue = workInProgress.updateQueue;164 if (updateQueue !== null) {165 instance.state = beginUpdateQueue(workInProgress, updateQueue, instance, state, props, priorityLevel);166 }167 }168 if (typeof instance.componentDidMount === 'function') {169 workInProgress.effectTag |= Update;170 }171 }172 function resumeMountClassInstance(workInProgress, priorityLevel) {173 var instance = workInProgress.stateNode;174 resetInputPointers(workInProgress, instance);175 var newState = workInProgress.memoizedState;176 var newProps = workInProgress.pendingProps;177 if (!newProps) {178 newProps = workInProgress.memoizedProps;179 invariant(newProps != null, 'There should always be pending or memoized props. This error is ' + 'likely caused by a bug in React. Please file an issue.');180 }181 var newUnmaskedContext = getUnmaskedContext(workInProgress);182 var newContext = getMaskedContext(workInProgress, newUnmaskedContext);183 if (!checkShouldComponentUpdate(workInProgress, workInProgress.memoizedProps, newProps, workInProgress.memoizedState, newState, newContext)) {184 instance.props = newProps;185 instance.state = newState;186 instance.context = newContext;187 return false;188 }189 var newInstance = constructClassInstance(workInProgress);190 newInstance.props = newProps;191 newInstance.state = newState = newInstance.state || null;192 newInstance.context = newContext;193 if (typeof newInstance.componentWillMount === 'function') {194 if (__DEV__) {195 startPhaseTimer(workInProgress, 'componentWillMount');196 }197 newInstance.componentWillMount();198 if (__DEV__) {199 stopPhaseTimer();200 }201 }202 var newUpdateQueue = workInProgress.updateQueue;203 if (newUpdateQueue !== null) {204 newInstance.state = beginUpdateQueue(workInProgress, newUpdateQueue, newInstance, newState, newProps, priorityLevel);205 }206 if (typeof instance.componentDidMount === 'function') {207 workInProgress.effectTag |= Update;208 }209 return true;210 }211 function updateClassInstance(current, workInProgress, priorityLevel) {212 var instance = workInProgress.stateNode;213 resetInputPointers(workInProgress, instance);214 var oldProps = workInProgress.memoizedProps;215 var newProps = workInProgress.pendingProps;216 if (!newProps) {217 newProps = oldProps;218 invariant(newProps != null, 'There should always be pending or memoized props. This error is ' + 'likely caused by a bug in React. Please file an issue.');219 }220 var oldContext = instance.context;221 var newUnmaskedContext = getUnmaskedContext(workInProgress);222 var newContext = getMaskedContext(workInProgress, newUnmaskedContext);223 if (oldProps !== newProps || oldContext !== newContext) {224 if (typeof instance.componentWillReceiveProps === 'function') {225 if (__DEV__) {226 startPhaseTimer(workInProgress, 'componentWillReceiveProps');227 }228 instance.componentWillReceiveProps(newProps, newContext);229 if (__DEV__) {230 stopPhaseTimer();231 }232 if (instance.state !== workInProgress.memoizedState) {233 if (__DEV__) {234 warning(false, '%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentName(workInProgress));235 }236 updater.enqueueReplaceState(instance, instance.state, null);237 }238 }239 }240 var updateQueue = workInProgress.updateQueue;241 var oldState = workInProgress.memoizedState;242 var newState = void 0;243 if (updateQueue !== null) {244 newState = beginUpdateQueue(workInProgress, updateQueue, instance, oldState, newProps, priorityLevel);245 } else {246 newState = oldState;247 }248 if (oldProps === newProps && oldState === newState && !hasContextChanged() && !(updateQueue !== null && updateQueue.hasForceUpdate)) {249 if (typeof instance.componentDidUpdate === 'function') {250 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {251 workInProgress.effectTag |= Update;252 }253 }254 return false;255 }256 var shouldUpdate = checkShouldComponentUpdate(workInProgress, oldProps, newProps, oldState, newState, newContext);257 if (shouldUpdate) {258 if (typeof instance.componentWillUpdate === 'function') {259 if (__DEV__) {260 startPhaseTimer(workInProgress, 'componentWillUpdate');261 }262 instance.componentWillUpdate(newProps, newState, newContext);263 if (__DEV__) {264 stopPhaseTimer();265 }266 }267 if (typeof instance.componentDidUpdate === 'function') {268 workInProgress.effectTag |= Update;269 }270 } else {271 if (typeof instance.componentDidUpdate === 'function') {272 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {273 workInProgress.effectTag |= Update;274 }275 }276 memoizeProps(workInProgress, newProps);277 memoizeState(workInProgress, newState);278 }...
63dfe97fc56ec59927fe7014929325c1aa846dReactFiberClassComponent.js
Source:63dfe97fc56ec59927fe7014929325c1aa846dReactFiberClassComponent.js
...74 startPhaseTimer(workInProgress, 'shouldComponentUpdate');75 }76 var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, newContext);77 if (__DEV__) {78 stopPhaseTimer();79 }80 if (__DEV__) {81 warning(shouldUpdate !== undefined, '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(workInProgress) || 'Unknown');82 }83 return shouldUpdate;84 }85 var type = workInProgress.type;86 if (type.prototype && type.prototype.isPureReactComponent) {87 return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState);88 }89 return true;90 }91 function checkClassInstance(workInProgress) {92 var instance = workInProgress.stateNode;93 if (__DEV__) {94 var name = getComponentName(workInProgress);95 var renderPresent = instance.render;96 warning(renderPresent, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name);97 var noGetInitialStateOnES6 = !instance.getInitialState || instance.getInitialState.isReactClassApproved || instance.state;98 warning(noGetInitialStateOnES6, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', name);99 var noGetDefaultPropsOnES6 = !instance.getDefaultProps || instance.getDefaultProps.isReactClassApproved;100 warning(noGetDefaultPropsOnES6, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', name);101 var noInstancePropTypes = !instance.propTypes;102 warning(noInstancePropTypes, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name);103 var noInstanceContextTypes = !instance.contextTypes;104 warning(noInstanceContextTypes, 'contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name);105 var noComponentShouldUpdate = typeof instance.componentShouldUpdate !== 'function';106 warning(noComponentShouldUpdate, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', name);107 var noComponentDidUnmount = typeof instance.componentDidUnmount !== 'function';108 warning(noComponentDidUnmount, '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name);109 var noComponentWillRecieveProps = typeof instance.componentWillRecieveProps !== 'function';110 warning(noComponentWillRecieveProps, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name);111 var hasMutatedProps = instance.props !== workInProgress.pendingProps;112 warning(instance.props === undefined || !hasMutatedProps, '%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name);113 }114 var state = instance.state;115 if (state && (typeof state !== 'object' || isArray(state))) {116 invariant(false, '%s.state: must be set to an object or null', getComponentName(workInProgress));117 }118 if (typeof instance.getChildContext === 'function') {119 invariant(typeof workInProgress.type.childContextTypes === 'object', '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', getComponentName(workInProgress));120 }121 }122 function resetInputPointers(workInProgress, instance) {123 instance.props = workInProgress.memoizedProps;124 instance.state = workInProgress.memoizedState;125 }126 function adoptClassInstance(workInProgress, instance) {127 instance.updater = updater;128 workInProgress.stateNode = instance;129 ReactInstanceMap.set(instance, workInProgress);130 }131 function constructClassInstance(workInProgress) {132 var ctor = workInProgress.type;133 var props = workInProgress.pendingProps;134 var unmaskedContext = getUnmaskedContext(workInProgress);135 var needsContext = isContextConsumer(workInProgress);136 var context = needsContext ? getMaskedContext(workInProgress, unmaskedContext) : emptyObject;137 var instance = new ctor(props, context);138 adoptClassInstance(workInProgress, instance);139 checkClassInstance(workInProgress);140 if (needsContext) {141 cacheContext(workInProgress, unmaskedContext, context);142 }143 return instance;144 }145 function mountClassInstance(workInProgress, priorityLevel) {146 var instance = workInProgress.stateNode;147 var state = instance.state || null;148 var props = workInProgress.pendingProps;149 invariant(props, 'There must be pending props for an initial mount. This error is ' + 'likely caused by a bug in React. Please file an issue.');150 var unmaskedContext = getUnmaskedContext(workInProgress);151 instance.props = props;152 instance.state = state;153 instance.refs = emptyObject;154 instance.context = getMaskedContext(workInProgress, unmaskedContext);155 if (typeof instance.componentWillMount === 'function') {156 if (__DEV__) {157 startPhaseTimer(workInProgress, 'componentWillMount');158 }159 instance.componentWillMount();160 if (__DEV__) {161 stopPhaseTimer();162 }163 var updateQueue = workInProgress.updateQueue;164 if (updateQueue !== null) {165 instance.state = beginUpdateQueue(workInProgress, updateQueue, instance, state, props, priorityLevel);166 }167 }168 if (typeof instance.componentDidMount === 'function') {169 workInProgress.effectTag |= Update;170 }171 }172 function resumeMountClassInstance(workInProgress, priorityLevel) {173 var instance = workInProgress.stateNode;174 resetInputPointers(workInProgress, instance);175 var newState = workInProgress.memoizedState;176 var newProps = workInProgress.pendingProps;177 if (!newProps) {178 newProps = workInProgress.memoizedProps;179 invariant(newProps != null, 'There should always be pending or memoized props. This error is ' + 'likely caused by a bug in React. Please file an issue.');180 }181 var newUnmaskedContext = getUnmaskedContext(workInProgress);182 var newContext = getMaskedContext(workInProgress, newUnmaskedContext);183 if (!checkShouldComponentUpdate(workInProgress, workInProgress.memoizedProps, newProps, workInProgress.memoizedState, newState, newContext)) {184 instance.props = newProps;185 instance.state = newState;186 instance.context = newContext;187 return false;188 }189 var newInstance = constructClassInstance(workInProgress);190 newInstance.props = newProps;191 newInstance.state = newState = newInstance.state || null;192 newInstance.context = newContext;193 if (typeof newInstance.componentWillMount === 'function') {194 if (__DEV__) {195 startPhaseTimer(workInProgress, 'componentWillMount');196 }197 newInstance.componentWillMount();198 if (__DEV__) {199 stopPhaseTimer();200 }201 }202 var newUpdateQueue = workInProgress.updateQueue;203 if (newUpdateQueue !== null) {204 newInstance.state = beginUpdateQueue(workInProgress, newUpdateQueue, newInstance, newState, newProps, priorityLevel);205 }206 if (typeof instance.componentDidMount === 'function') {207 workInProgress.effectTag |= Update;208 }209 return true;210 }211 function updateClassInstance(current, workInProgress, priorityLevel) {212 var instance = workInProgress.stateNode;213 resetInputPointers(workInProgress, instance);214 var oldProps = workInProgress.memoizedProps;215 var newProps = workInProgress.pendingProps;216 if (!newProps) {217 newProps = oldProps;218 invariant(newProps != null, 'There should always be pending or memoized props. This error is ' + 'likely caused by a bug in React. Please file an issue.');219 }220 var oldContext = instance.context;221 var newUnmaskedContext = getUnmaskedContext(workInProgress);222 var newContext = getMaskedContext(workInProgress, newUnmaskedContext);223 if (oldProps !== newProps || oldContext !== newContext) {224 if (typeof instance.componentWillReceiveProps === 'function') {225 if (__DEV__) {226 startPhaseTimer(workInProgress, 'componentWillReceiveProps');227 }228 instance.componentWillReceiveProps(newProps, newContext);229 if (__DEV__) {230 stopPhaseTimer();231 }232 if (instance.state !== workInProgress.memoizedState) {233 if (__DEV__) {234 warning(false, '%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentName(workInProgress));235 }236 updater.enqueueReplaceState(instance, instance.state, null);237 }238 }239 }240 var updateQueue = workInProgress.updateQueue;241 var oldState = workInProgress.memoizedState;242 var newState = void 0;243 if (updateQueue !== null) {244 newState = beginUpdateQueue(workInProgress, updateQueue, instance, oldState, newProps, priorityLevel);245 } else {246 newState = oldState;247 }248 if (oldProps === newProps && oldState === newState && !hasContextChanged() && !(updateQueue !== null && updateQueue.hasForceUpdate)) {249 if (typeof instance.componentDidUpdate === 'function') {250 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {251 workInProgress.effectTag |= Update;252 }253 }254 return false;255 }256 var shouldUpdate = checkShouldComponentUpdate(workInProgress, oldProps, newProps, oldState, newState, newContext);257 if (shouldUpdate) {258 if (typeof instance.componentWillUpdate === 'function') {259 if (__DEV__) {260 startPhaseTimer(workInProgress, 'componentWillUpdate');261 }262 instance.componentWillUpdate(newProps, newState, newContext);263 if (__DEV__) {264 stopPhaseTimer();265 }266 }267 if (typeof instance.componentDidUpdate === 'function') {268 workInProgress.effectTag |= Update;269 }270 } else {271 if (typeof instance.componentDidUpdate === 'function') {272 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {273 workInProgress.effectTag |= Update;274 }275 }276 memoizeProps(workInProgress, newProps);277 memoizeState(workInProgress, newState);278 }...
5189058ca83259b19f61a71152c744cf5554ccReactFiberClassComponent.js
Source:5189058ca83259b19f61a71152c744cf5554ccReactFiberClassComponent.js
...74 startPhaseTimer(workInProgress, 'shouldComponentUpdate');75 }76 var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, newContext);77 if (__DEV__) {78 stopPhaseTimer();79 }80 if (__DEV__) {81 warning(shouldUpdate !== undefined, '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(workInProgress) || 'Unknown');82 }83 return shouldUpdate;84 }85 var type = workInProgress.type;86 if (type.prototype && type.prototype.isPureReactComponent) {87 return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState);88 }89 return true;90 }91 function checkClassInstance(workInProgress) {92 var instance = workInProgress.stateNode;93 if (__DEV__) {94 var name = getComponentName(workInProgress);95 var renderPresent = instance.render;96 warning(renderPresent, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name);97 var noGetInitialStateOnES6 = !instance.getInitialState || instance.getInitialState.isReactClassApproved || instance.state;98 warning(noGetInitialStateOnES6, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', name);99 var noGetDefaultPropsOnES6 = !instance.getDefaultProps || instance.getDefaultProps.isReactClassApproved;100 warning(noGetDefaultPropsOnES6, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', name);101 var noInstancePropTypes = !instance.propTypes;102 warning(noInstancePropTypes, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name);103 var noInstanceContextTypes = !instance.contextTypes;104 warning(noInstanceContextTypes, 'contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name);105 var noComponentShouldUpdate = typeof instance.componentShouldUpdate !== 'function';106 warning(noComponentShouldUpdate, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', name);107 var noComponentDidUnmount = typeof instance.componentDidUnmount !== 'function';108 warning(noComponentDidUnmount, '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name);109 var noComponentWillRecieveProps = typeof instance.componentWillRecieveProps !== 'function';110 warning(noComponentWillRecieveProps, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name);111 var hasMutatedProps = instance.props !== workInProgress.pendingProps;112 warning(instance.props === undefined || !hasMutatedProps, '%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name);113 }114 var state = instance.state;115 if (state && (typeof state !== 'object' || isArray(state))) {116 invariant(false, '%s.state: must be set to an object or null', getComponentName(workInProgress));117 }118 if (typeof instance.getChildContext === 'function') {119 invariant(typeof workInProgress.type.childContextTypes === 'object', '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', getComponentName(workInProgress));120 }121 }122 function resetInputPointers(workInProgress, instance) {123 instance.props = workInProgress.memoizedProps;124 instance.state = workInProgress.memoizedState;125 }126 function adoptClassInstance(workInProgress, instance) {127 instance.updater = updater;128 workInProgress.stateNode = instance;129 ReactInstanceMap.set(instance, workInProgress);130 }131 function constructClassInstance(workInProgress) {132 var ctor = workInProgress.type;133 var props = workInProgress.pendingProps;134 var unmaskedContext = getUnmaskedContext(workInProgress);135 var needsContext = isContextConsumer(workInProgress);136 var context = needsContext ? getMaskedContext(workInProgress, unmaskedContext) : emptyObject;137 var instance = new ctor(props, context);138 adoptClassInstance(workInProgress, instance);139 checkClassInstance(workInProgress);140 if (needsContext) {141 cacheContext(workInProgress, unmaskedContext, context);142 }143 return instance;144 }145 function mountClassInstance(workInProgress, priorityLevel) {146 var instance = workInProgress.stateNode;147 var state = instance.state || null;148 var props = workInProgress.pendingProps;149 invariant(props, 'There must be pending props for an initial mount. This error is ' + 'likely caused by a bug in React. Please file an issue.');150 var unmaskedContext = getUnmaskedContext(workInProgress);151 instance.props = props;152 instance.state = state;153 instance.refs = emptyObject;154 instance.context = getMaskedContext(workInProgress, unmaskedContext);155 if (typeof instance.componentWillMount === 'function') {156 if (__DEV__) {157 startPhaseTimer(workInProgress, 'componentWillMount');158 }159 instance.componentWillMount();160 if (__DEV__) {161 stopPhaseTimer();162 }163 var updateQueue = workInProgress.updateQueue;164 if (updateQueue !== null) {165 instance.state = beginUpdateQueue(workInProgress, updateQueue, instance, state, props, priorityLevel);166 }167 }168 if (typeof instance.componentDidMount === 'function') {169 workInProgress.effectTag |= Update;170 }171 }172 function resumeMountClassInstance(workInProgress, priorityLevel) {173 var instance = workInProgress.stateNode;174 resetInputPointers(workInProgress, instance);175 var newState = workInProgress.memoizedState;176 var newProps = workInProgress.pendingProps;177 if (!newProps) {178 newProps = workInProgress.memoizedProps;179 invariant(newProps != null, 'There should always be pending or memoized props. This error is ' + 'likely caused by a bug in React. Please file an issue.');180 }181 var newUnmaskedContext = getUnmaskedContext(workInProgress);182 var newContext = getMaskedContext(workInProgress, newUnmaskedContext);183 if (!checkShouldComponentUpdate(workInProgress, workInProgress.memoizedProps, newProps, workInProgress.memoizedState, newState, newContext)) {184 instance.props = newProps;185 instance.state = newState;186 instance.context = newContext;187 return false;188 }189 var newInstance = constructClassInstance(workInProgress);190 newInstance.props = newProps;191 newInstance.state = newState = newInstance.state || null;192 newInstance.context = newContext;193 if (typeof newInstance.componentWillMount === 'function') {194 if (__DEV__) {195 startPhaseTimer(workInProgress, 'componentWillMount');196 }197 newInstance.componentWillMount();198 if (__DEV__) {199 stopPhaseTimer();200 }201 }202 var newUpdateQueue = workInProgress.updateQueue;203 if (newUpdateQueue !== null) {204 newInstance.state = beginUpdateQueue(workInProgress, newUpdateQueue, newInstance, newState, newProps, priorityLevel);205 }206 if (typeof instance.componentDidMount === 'function') {207 workInProgress.effectTag |= Update;208 }209 return true;210 }211 function updateClassInstance(current, workInProgress, priorityLevel) {212 var instance = workInProgress.stateNode;213 resetInputPointers(workInProgress, instance);214 var oldProps = workInProgress.memoizedProps;215 var newProps = workInProgress.pendingProps;216 if (!newProps) {217 newProps = oldProps;218 invariant(newProps != null, 'There should always be pending or memoized props. This error is ' + 'likely caused by a bug in React. Please file an issue.');219 }220 var oldContext = instance.context;221 var newUnmaskedContext = getUnmaskedContext(workInProgress);222 var newContext = getMaskedContext(workInProgress, newUnmaskedContext);223 if (oldProps !== newProps || oldContext !== newContext) {224 if (typeof instance.componentWillReceiveProps === 'function') {225 if (__DEV__) {226 startPhaseTimer(workInProgress, 'componentWillReceiveProps');227 }228 instance.componentWillReceiveProps(newProps, newContext);229 if (__DEV__) {230 stopPhaseTimer();231 }232 if (instance.state !== workInProgress.memoizedState) {233 if (__DEV__) {234 warning(false, '%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentName(workInProgress));235 }236 updater.enqueueReplaceState(instance, instance.state, null);237 }238 }239 }240 var updateQueue = workInProgress.updateQueue;241 var oldState = workInProgress.memoizedState;242 var newState = void 0;243 if (updateQueue !== null) {244 newState = beginUpdateQueue(workInProgress, updateQueue, instance, oldState, newProps, priorityLevel);245 } else {246 newState = oldState;247 }248 if (oldProps === newProps && oldState === newState && !hasContextChanged() && !(updateQueue !== null && updateQueue.hasForceUpdate)) {249 if (typeof instance.componentDidUpdate === 'function') {250 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {251 workInProgress.effectTag |= Update;252 }253 }254 return false;255 }256 var shouldUpdate = checkShouldComponentUpdate(workInProgress, oldProps, newProps, oldState, newState, newContext);257 if (shouldUpdate) {258 if (typeof instance.componentWillUpdate === 'function') {259 if (__DEV__) {260 startPhaseTimer(workInProgress, 'componentWillUpdate');261 }262 instance.componentWillUpdate(newProps, newState, newContext);263 if (__DEV__) {264 stopPhaseTimer();265 }266 }267 if (typeof instance.componentDidUpdate === 'function') {268 workInProgress.effectTag |= Update;269 }270 } else {271 if (typeof instance.componentDidUpdate === 'function') {272 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {273 workInProgress.effectTag |= Update;274 }275 }276 memoizeProps(workInProgress, newProps);277 memoizeState(workInProgress, newState);278 }...
e5881c9fce00eba262a698b097b520392b5a8eReactFiberClassComponent.js
Source:e5881c9fce00eba262a698b097b520392b5a8eReactFiberClassComponent.js
...74 startPhaseTimer(workInProgress, 'shouldComponentUpdate');75 }76 var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, newContext);77 if (__DEV__) {78 stopPhaseTimer();79 }80 if (__DEV__) {81 warning(shouldUpdate !== undefined, '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(workInProgress) || 'Unknown');82 }83 return shouldUpdate;84 }85 var type = workInProgress.type;86 if (type.prototype && type.prototype.isPureReactComponent) {87 return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState);88 }89 return true;90 }91 function checkClassInstance(workInProgress) {92 var instance = workInProgress.stateNode;93 if (__DEV__) {94 var name = getComponentName(workInProgress);95 var renderPresent = instance.render;96 warning(renderPresent, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name);97 var noGetInitialStateOnES6 = !instance.getInitialState || instance.getInitialState.isReactClassApproved || instance.state;98 warning(noGetInitialStateOnES6, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', name);99 var noGetDefaultPropsOnES6 = !instance.getDefaultProps || instance.getDefaultProps.isReactClassApproved;100 warning(noGetDefaultPropsOnES6, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', name);101 var noInstancePropTypes = !instance.propTypes;102 warning(noInstancePropTypes, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name);103 var noInstanceContextTypes = !instance.contextTypes;104 warning(noInstanceContextTypes, 'contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name);105 var noComponentShouldUpdate = typeof instance.componentShouldUpdate !== 'function';106 warning(noComponentShouldUpdate, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', name);107 var noComponentDidUnmount = typeof instance.componentDidUnmount !== 'function';108 warning(noComponentDidUnmount, '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name);109 var noComponentWillRecieveProps = typeof instance.componentWillRecieveProps !== 'function';110 warning(noComponentWillRecieveProps, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name);111 var hasMutatedProps = instance.props !== workInProgress.pendingProps;112 warning(instance.props === undefined || !hasMutatedProps, '%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name);113 }114 var state = instance.state;115 if (state && (typeof state !== 'object' || isArray(state))) {116 invariant(false, '%s.state: must be set to an object or null', getComponentName(workInProgress));117 }118 if (typeof instance.getChildContext === 'function') {119 invariant(typeof workInProgress.type.childContextTypes === 'object', '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', getComponentName(workInProgress));120 }121 }122 function resetInputPointers(workInProgress, instance) {123 instance.props = workInProgress.memoizedProps;124 instance.state = workInProgress.memoizedState;125 }126 function adoptClassInstance(workInProgress, instance) {127 instance.updater = updater;128 workInProgress.stateNode = instance;129 ReactInstanceMap.set(instance, workInProgress);130 }131 function constructClassInstance(workInProgress) {132 var ctor = workInProgress.type;133 var props = workInProgress.pendingProps;134 var unmaskedContext = getUnmaskedContext(workInProgress);135 var needsContext = isContextConsumer(workInProgress);136 var context = needsContext ? getMaskedContext(workInProgress, unmaskedContext) : emptyObject;137 var instance = new ctor(props, context);138 adoptClassInstance(workInProgress, instance);139 checkClassInstance(workInProgress);140 if (needsContext) {141 cacheContext(workInProgress, unmaskedContext, context);142 }143 return instance;144 }145 function mountClassInstance(workInProgress, priorityLevel) {146 var instance = workInProgress.stateNode;147 var state = instance.state || null;148 var props = workInProgress.pendingProps;149 invariant(props, 'There must be pending props for an initial mount. This error is ' + 'likely caused by a bug in React. Please file an issue.');150 var unmaskedContext = getUnmaskedContext(workInProgress);151 instance.props = props;152 instance.state = state;153 instance.refs = emptyObject;154 instance.context = getMaskedContext(workInProgress, unmaskedContext);155 if (typeof instance.componentWillMount === 'function') {156 if (__DEV__) {157 startPhaseTimer(workInProgress, 'componentWillMount');158 }159 instance.componentWillMount();160 if (__DEV__) {161 stopPhaseTimer();162 }163 var updateQueue = workInProgress.updateQueue;164 if (updateQueue !== null) {165 instance.state = beginUpdateQueue(workInProgress, updateQueue, instance, state, props, priorityLevel);166 }167 }168 if (typeof instance.componentDidMount === 'function') {169 workInProgress.effectTag |= Update;170 }171 }172 function resumeMountClassInstance(workInProgress, priorityLevel) {173 var instance = workInProgress.stateNode;174 resetInputPointers(workInProgress, instance);175 var newState = workInProgress.memoizedState;176 var newProps = workInProgress.pendingProps;177 if (!newProps) {178 newProps = workInProgress.memoizedProps;179 invariant(newProps != null, 'There should always be pending or memoized props. This error is ' + 'likely caused by a bug in React. Please file an issue.');180 }181 var newUnmaskedContext = getUnmaskedContext(workInProgress);182 var newContext = getMaskedContext(workInProgress, newUnmaskedContext);183 if (!checkShouldComponentUpdate(workInProgress, workInProgress.memoizedProps, newProps, workInProgress.memoizedState, newState, newContext)) {184 instance.props = newProps;185 instance.state = newState;186 instance.context = newContext;187 return false;188 }189 var newInstance = constructClassInstance(workInProgress);190 newInstance.props = newProps;191 newInstance.state = newState = newInstance.state || null;192 newInstance.context = newContext;193 if (typeof newInstance.componentWillMount === 'function') {194 if (__DEV__) {195 startPhaseTimer(workInProgress, 'componentWillMount');196 }197 newInstance.componentWillMount();198 if (__DEV__) {199 stopPhaseTimer();200 }201 }202 var newUpdateQueue = workInProgress.updateQueue;203 if (newUpdateQueue !== null) {204 newInstance.state = beginUpdateQueue(workInProgress, newUpdateQueue, newInstance, newState, newProps, priorityLevel);205 }206 if (typeof instance.componentDidMount === 'function') {207 workInProgress.effectTag |= Update;208 }209 return true;210 }211 function updateClassInstance(current, workInProgress, priorityLevel) {212 var instance = workInProgress.stateNode;213 resetInputPointers(workInProgress, instance);214 var oldProps = workInProgress.memoizedProps;215 var newProps = workInProgress.pendingProps;216 if (!newProps) {217 newProps = oldProps;218 invariant(newProps != null, 'There should always be pending or memoized props. This error is ' + 'likely caused by a bug in React. Please file an issue.');219 }220 var oldContext = instance.context;221 var newUnmaskedContext = getUnmaskedContext(workInProgress);222 var newContext = getMaskedContext(workInProgress, newUnmaskedContext);223 if (oldProps !== newProps || oldContext !== newContext) {224 if (typeof instance.componentWillReceiveProps === 'function') {225 if (__DEV__) {226 startPhaseTimer(workInProgress, 'componentWillReceiveProps');227 }228 instance.componentWillReceiveProps(newProps, newContext);229 if (__DEV__) {230 stopPhaseTimer();231 }232 if (instance.state !== workInProgress.memoizedState) {233 if (__DEV__) {234 warning(false, '%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentName(workInProgress));235 }236 updater.enqueueReplaceState(instance, instance.state, null);237 }238 }239 }240 var updateQueue = workInProgress.updateQueue;241 var oldState = workInProgress.memoizedState;242 var newState = void 0;243 if (updateQueue !== null) {244 newState = beginUpdateQueue(workInProgress, updateQueue, instance, oldState, newProps, priorityLevel);245 } else {246 newState = oldState;247 }248 if (oldProps === newProps && oldState === newState && !hasContextChanged() && !(updateQueue !== null && updateQueue.hasForceUpdate)) {249 if (typeof instance.componentDidUpdate === 'function') {250 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {251 workInProgress.effectTag |= Update;252 }253 }254 return false;255 }256 var shouldUpdate = checkShouldComponentUpdate(workInProgress, oldProps, newProps, oldState, newState, newContext);257 if (shouldUpdate) {258 if (typeof instance.componentWillUpdate === 'function') {259 if (__DEV__) {260 startPhaseTimer(workInProgress, 'componentWillUpdate');261 }262 instance.componentWillUpdate(newProps, newState, newContext);263 if (__DEV__) {264 stopPhaseTimer();265 }266 }267 if (typeof instance.componentDidUpdate === 'function') {268 workInProgress.effectTag |= Update;269 }270 } else {271 if (typeof instance.componentDidUpdate === 'function') {272 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {273 workInProgress.effectTag |= Update;274 }275 }276 memoizeProps(workInProgress, newProps);277 memoizeState(workInProgress, newState);278 }...
8ca7de39eb8464178ca86a85535ed9229f99f3ReactFiberClassComponent.js
Source:8ca7de39eb8464178ca86a85535ed9229f99f3ReactFiberClassComponent.js
...74 startPhaseTimer(workInProgress, 'shouldComponentUpdate');75 }76 var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, newContext);77 if (__DEV__) {78 stopPhaseTimer();79 }80 if (__DEV__) {81 warning(shouldUpdate !== undefined, '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(workInProgress) || 'Unknown');82 }83 return shouldUpdate;84 }85 var type = workInProgress.type;86 if (type.prototype && type.prototype.isPureReactComponent) {87 return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState);88 }89 return true;90 }91 function checkClassInstance(workInProgress) {92 var instance = workInProgress.stateNode;93 if (__DEV__) {94 var name = getComponentName(workInProgress);95 var renderPresent = instance.render;96 warning(renderPresent, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name);97 var noGetInitialStateOnES6 = !instance.getInitialState || instance.getInitialState.isReactClassApproved || instance.state;98 warning(noGetInitialStateOnES6, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', name);99 var noGetDefaultPropsOnES6 = !instance.getDefaultProps || instance.getDefaultProps.isReactClassApproved;100 warning(noGetDefaultPropsOnES6, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', name);101 var noInstancePropTypes = !instance.propTypes;102 warning(noInstancePropTypes, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name);103 var noInstanceContextTypes = !instance.contextTypes;104 warning(noInstanceContextTypes, 'contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name);105 var noComponentShouldUpdate = typeof instance.componentShouldUpdate !== 'function';106 warning(noComponentShouldUpdate, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', name);107 var noComponentDidUnmount = typeof instance.componentDidUnmount !== 'function';108 warning(noComponentDidUnmount, '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name);109 var noComponentWillRecieveProps = typeof instance.componentWillRecieveProps !== 'function';110 warning(noComponentWillRecieveProps, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name);111 var hasMutatedProps = instance.props !== workInProgress.pendingProps;112 warning(instance.props === undefined || !hasMutatedProps, '%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name);113 }114 var state = instance.state;115 if (state && (typeof state !== 'object' || isArray(state))) {116 invariant(false, '%s.state: must be set to an object or null', getComponentName(workInProgress));117 }118 if (typeof instance.getChildContext === 'function') {119 invariant(typeof workInProgress.type.childContextTypes === 'object', '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', getComponentName(workInProgress));120 }121 }122 function resetInputPointers(workInProgress, instance) {123 instance.props = workInProgress.memoizedProps;124 instance.state = workInProgress.memoizedState;125 }126 function adoptClassInstance(workInProgress, instance) {127 instance.updater = updater;128 workInProgress.stateNode = instance;129 ReactInstanceMap.set(instance, workInProgress);130 }131 function constructClassInstance(workInProgress) {132 var ctor = workInProgress.type;133 var props = workInProgress.pendingProps;134 var unmaskedContext = getUnmaskedContext(workInProgress);135 var needsContext = isContextConsumer(workInProgress);136 var context = needsContext ? getMaskedContext(workInProgress, unmaskedContext) : emptyObject;137 var instance = new ctor(props, context);138 adoptClassInstance(workInProgress, instance);139 checkClassInstance(workInProgress);140 if (needsContext) {141 cacheContext(workInProgress, unmaskedContext, context);142 }143 return instance;144 }145 function mountClassInstance(workInProgress, priorityLevel) {146 var instance = workInProgress.stateNode;147 var state = instance.state || null;148 var props = workInProgress.pendingProps;149 invariant(props, 'There must be pending props for an initial mount. This error is ' + 'likely caused by a bug in React. Please file an issue.');150 var unmaskedContext = getUnmaskedContext(workInProgress);151 instance.props = props;152 instance.state = state;153 instance.refs = emptyObject;154 instance.context = getMaskedContext(workInProgress, unmaskedContext);155 if (typeof instance.componentWillMount === 'function') {156 if (__DEV__) {157 startPhaseTimer(workInProgress, 'componentWillMount');158 }159 instance.componentWillMount();160 if (__DEV__) {161 stopPhaseTimer();162 }163 var updateQueue = workInProgress.updateQueue;164 if (updateQueue !== null) {165 instance.state = beginUpdateQueue(workInProgress, updateQueue, instance, state, props, priorityLevel);166 }167 }168 if (typeof instance.componentDidMount === 'function') {169 workInProgress.effectTag |= Update;170 }171 }172 function resumeMountClassInstance(workInProgress, priorityLevel) {173 var instance = workInProgress.stateNode;174 resetInputPointers(workInProgress, instance);175 var newState = workInProgress.memoizedState;176 var newProps = workInProgress.pendingProps;177 if (!newProps) {178 newProps = workInProgress.memoizedProps;179 invariant(newProps != null, 'There should always be pending or memoized props. This error is ' + 'likely caused by a bug in React. Please file an issue.');180 }181 var newUnmaskedContext = getUnmaskedContext(workInProgress);182 var newContext = getMaskedContext(workInProgress, newUnmaskedContext);183 if (!checkShouldComponentUpdate(workInProgress, workInProgress.memoizedProps, newProps, workInProgress.memoizedState, newState, newContext)) {184 instance.props = newProps;185 instance.state = newState;186 instance.context = newContext;187 return false;188 }189 var newInstance = constructClassInstance(workInProgress);190 newInstance.props = newProps;191 newInstance.state = newState = newInstance.state || null;192 newInstance.context = newContext;193 if (typeof newInstance.componentWillMount === 'function') {194 if (__DEV__) {195 startPhaseTimer(workInProgress, 'componentWillMount');196 }197 newInstance.componentWillMount();198 if (__DEV__) {199 stopPhaseTimer();200 }201 }202 var newUpdateQueue = workInProgress.updateQueue;203 if (newUpdateQueue !== null) {204 newInstance.state = beginUpdateQueue(workInProgress, newUpdateQueue, newInstance, newState, newProps, priorityLevel);205 }206 if (typeof instance.componentDidMount === 'function') {207 workInProgress.effectTag |= Update;208 }209 return true;210 }211 function updateClassInstance(current, workInProgress, priorityLevel) {212 var instance = workInProgress.stateNode;213 resetInputPointers(workInProgress, instance);214 var oldProps = workInProgress.memoizedProps;215 var newProps = workInProgress.pendingProps;216 if (!newProps) {217 newProps = oldProps;218 invariant(newProps != null, 'There should always be pending or memoized props. This error is ' + 'likely caused by a bug in React. Please file an issue.');219 }220 var oldContext = instance.context;221 var newUnmaskedContext = getUnmaskedContext(workInProgress);222 var newContext = getMaskedContext(workInProgress, newUnmaskedContext);223 if (oldProps !== newProps || oldContext !== newContext) {224 if (typeof instance.componentWillReceiveProps === 'function') {225 if (__DEV__) {226 startPhaseTimer(workInProgress, 'componentWillReceiveProps');227 }228 instance.componentWillReceiveProps(newProps, newContext);229 if (__DEV__) {230 stopPhaseTimer();231 }232 if (instance.state !== workInProgress.memoizedState) {233 if (__DEV__) {234 warning(false, '%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentName(workInProgress));235 }236 updater.enqueueReplaceState(instance, instance.state, null);237 }238 }239 }240 var updateQueue = workInProgress.updateQueue;241 var oldState = workInProgress.memoizedState;242 var newState = void 0;243 if (updateQueue !== null) {244 newState = beginUpdateQueue(workInProgress, updateQueue, instance, oldState, newProps, priorityLevel);245 } else {246 newState = oldState;247 }248 if (oldProps === newProps && oldState === newState && !hasContextChanged() && !(updateQueue !== null && updateQueue.hasForceUpdate)) {249 if (typeof instance.componentDidUpdate === 'function') {250 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {251 workInProgress.effectTag |= Update;252 }253 }254 return false;255 }256 var shouldUpdate = checkShouldComponentUpdate(workInProgress, oldProps, newProps, oldState, newState, newContext);257 if (shouldUpdate) {258 if (typeof instance.componentWillUpdate === 'function') {259 if (__DEV__) {260 startPhaseTimer(workInProgress, 'componentWillUpdate');261 }262 instance.componentWillUpdate(newProps, newState, newContext);263 if (__DEV__) {264 stopPhaseTimer();265 }266 }267 if (typeof instance.componentDidUpdate === 'function') {268 workInProgress.effectTag |= Update;269 }270 } else {271 if (typeof instance.componentDidUpdate === 'function') {272 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {273 workInProgress.effectTag |= Update;274 }275 }276 memoizeProps(workInProgress, newProps);277 memoizeState(workInProgress, newState);278 }...
75b9d1e39129e9bda52599b1ccdca6dc979f73ReactFiberClassComponent.js
Source:75b9d1e39129e9bda52599b1ccdca6dc979f73ReactFiberClassComponent.js
...74 startPhaseTimer(workInProgress, 'shouldComponentUpdate');75 }76 var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, newContext);77 if (__DEV__) {78 stopPhaseTimer();79 }80 if (__DEV__) {81 warning(shouldUpdate !== undefined, '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(workInProgress) || 'Unknown');82 }83 return shouldUpdate;84 }85 var type = workInProgress.type;86 if (type.prototype && type.prototype.isPureReactComponent) {87 return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState);88 }89 return true;90 }91 function checkClassInstance(workInProgress) {92 var instance = workInProgress.stateNode;93 if (__DEV__) {94 var name = getComponentName(workInProgress);95 var renderPresent = instance.render;96 warning(renderPresent, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name);97 var noGetInitialStateOnES6 = !instance.getInitialState || instance.getInitialState.isReactClassApproved || instance.state;98 warning(noGetInitialStateOnES6, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', name);99 var noGetDefaultPropsOnES6 = !instance.getDefaultProps || instance.getDefaultProps.isReactClassApproved;100 warning(noGetDefaultPropsOnES6, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', name);101 var noInstancePropTypes = !instance.propTypes;102 warning(noInstancePropTypes, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name);103 var noInstanceContextTypes = !instance.contextTypes;104 warning(noInstanceContextTypes, 'contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name);105 var noComponentShouldUpdate = typeof instance.componentShouldUpdate !== 'function';106 warning(noComponentShouldUpdate, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', name);107 var noComponentDidUnmount = typeof instance.componentDidUnmount !== 'function';108 warning(noComponentDidUnmount, '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name);109 var noComponentWillRecieveProps = typeof instance.componentWillRecieveProps !== 'function';110 warning(noComponentWillRecieveProps, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name);111 var hasMutatedProps = instance.props !== workInProgress.pendingProps;112 warning(instance.props === undefined || !hasMutatedProps, '%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name);113 }114 var state = instance.state;115 if (state && (typeof state !== 'object' || isArray(state))) {116 invariant(false, '%s.state: must be set to an object or null', getComponentName(workInProgress));117 }118 if (typeof instance.getChildContext === 'function') {119 invariant(typeof workInProgress.type.childContextTypes === 'object', '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', getComponentName(workInProgress));120 }121 }122 function resetInputPointers(workInProgress, instance) {123 instance.props = workInProgress.memoizedProps;124 instance.state = workInProgress.memoizedState;125 }126 function adoptClassInstance(workInProgress, instance) {127 instance.updater = updater;128 workInProgress.stateNode = instance;129 ReactInstanceMap.set(instance, workInProgress);130 }131 function constructClassInstance(workInProgress) {132 var ctor = workInProgress.type;133 var props = workInProgress.pendingProps;134 var unmaskedContext = getUnmaskedContext(workInProgress);135 var needsContext = isContextConsumer(workInProgress);136 var context = needsContext ? getMaskedContext(workInProgress, unmaskedContext) : emptyObject;137 var instance = new ctor(props, context);138 adoptClassInstance(workInProgress, instance);139 checkClassInstance(workInProgress);140 if (needsContext) {141 cacheContext(workInProgress, unmaskedContext, context);142 }143 return instance;144 }145 function mountClassInstance(workInProgress, priorityLevel) {146 var instance = workInProgress.stateNode;147 var state = instance.state || null;148 var props = workInProgress.pendingProps;149 invariant(props, 'There must be pending props for an initial mount. This error is ' + 'likely caused by a bug in React. Please file an issue.');150 var unmaskedContext = getUnmaskedContext(workInProgress);151 instance.props = props;152 instance.state = state;153 instance.refs = emptyObject;154 instance.context = getMaskedContext(workInProgress, unmaskedContext);155 if (typeof instance.componentWillMount === 'function') {156 if (__DEV__) {157 startPhaseTimer(workInProgress, 'componentWillMount');158 }159 instance.componentWillMount();160 if (__DEV__) {161 stopPhaseTimer();162 }163 var updateQueue = workInProgress.updateQueue;164 if (updateQueue !== null) {165 instance.state = beginUpdateQueue(workInProgress, updateQueue, instance, state, props, priorityLevel);166 }167 }168 if (typeof instance.componentDidMount === 'function') {169 workInProgress.effectTag |= Update;170 }171 }172 function resumeMountClassInstance(workInProgress, priorityLevel) {173 var instance = workInProgress.stateNode;174 resetInputPointers(workInProgress, instance);175 var newState = workInProgress.memoizedState;176 var newProps = workInProgress.pendingProps;177 if (!newProps) {178 newProps = workInProgress.memoizedProps;179 invariant(newProps != null, 'There should always be pending or memoized props. This error is ' + 'likely caused by a bug in React. Please file an issue.');180 }181 var newUnmaskedContext = getUnmaskedContext(workInProgress);182 var newContext = getMaskedContext(workInProgress, newUnmaskedContext);183 if (!checkShouldComponentUpdate(workInProgress, workInProgress.memoizedProps, newProps, workInProgress.memoizedState, newState, newContext)) {184 instance.props = newProps;185 instance.state = newState;186 instance.context = newContext;187 return false;188 }189 var newInstance = constructClassInstance(workInProgress);190 newInstance.props = newProps;191 newInstance.state = newState = newInstance.state || null;192 newInstance.context = newContext;193 if (typeof newInstance.componentWillMount === 'function') {194 if (__DEV__) {195 startPhaseTimer(workInProgress, 'componentWillMount');196 }197 newInstance.componentWillMount();198 if (__DEV__) {199 stopPhaseTimer();200 }201 }202 var newUpdateQueue = workInProgress.updateQueue;203 if (newUpdateQueue !== null) {204 newInstance.state = beginUpdateQueue(workInProgress, newUpdateQueue, newInstance, newState, newProps, priorityLevel);205 }206 if (typeof instance.componentDidMount === 'function') {207 workInProgress.effectTag |= Update;208 }209 return true;210 }211 function updateClassInstance(current, workInProgress, priorityLevel) {212 var instance = workInProgress.stateNode;213 resetInputPointers(workInProgress, instance);214 var oldProps = workInProgress.memoizedProps;215 var newProps = workInProgress.pendingProps;216 if (!newProps) {217 newProps = oldProps;218 invariant(newProps != null, 'There should always be pending or memoized props. This error is ' + 'likely caused by a bug in React. Please file an issue.');219 }220 var oldContext = instance.context;221 var newUnmaskedContext = getUnmaskedContext(workInProgress);222 var newContext = getMaskedContext(workInProgress, newUnmaskedContext);223 if (oldProps !== newProps || oldContext !== newContext) {224 if (typeof instance.componentWillReceiveProps === 'function') {225 if (__DEV__) {226 startPhaseTimer(workInProgress, 'componentWillReceiveProps');227 }228 instance.componentWillReceiveProps(newProps, newContext);229 if (__DEV__) {230 stopPhaseTimer();231 }232 if (instance.state !== workInProgress.memoizedState) {233 if (__DEV__) {234 warning(false, '%s.componentWillReceiveProps(): Assigning directly to ' + "this.state is deprecated (except inside a component's " + 'constructor). Use setState instead.', getComponentName(workInProgress));235 }236 updater.enqueueReplaceState(instance, instance.state, null);237 }238 }239 }240 var updateQueue = workInProgress.updateQueue;241 var oldState = workInProgress.memoizedState;242 var newState = void 0;243 if (updateQueue !== null) {244 newState = beginUpdateQueue(workInProgress, updateQueue, instance, oldState, newProps, priorityLevel);245 } else {246 newState = oldState;247 }248 if (oldProps === newProps && oldState === newState && !hasContextChanged() && !(updateQueue !== null && updateQueue.hasForceUpdate)) {249 if (typeof instance.componentDidUpdate === 'function') {250 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {251 workInProgress.effectTag |= Update;252 }253 }254 return false;255 }256 var shouldUpdate = checkShouldComponentUpdate(workInProgress, oldProps, newProps, oldState, newState, newContext);257 if (shouldUpdate) {258 if (typeof instance.componentWillUpdate === 'function') {259 if (__DEV__) {260 startPhaseTimer(workInProgress, 'componentWillUpdate');261 }262 instance.componentWillUpdate(newProps, newState, newContext);263 if (__DEV__) {264 stopPhaseTimer();265 }266 }267 if (typeof instance.componentDidUpdate === 'function') {268 workInProgress.effectTag |= Update;269 }270 } else {271 if (typeof instance.componentDidUpdate === 'function') {272 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {273 workInProgress.effectTag |= Update;274 }275 }276 memoizeProps(workInProgress, newProps);277 memoizeState(workInProgress, newState);278 }...
ReactFiberContext.js
Source:ReactFiberContext.js
...16 }17 let childContext;18 startPhaseTimer(fiber, 'getChildContext');19 childContext = instance.getChildContext();20 stopPhaseTimer();21 22 return {...parentContext, ...childContext};23}24export function findCurrentUnmaskedContext(fiber: Fiber): Object {25 let node: Fiber = fiber;26 while (node.tag !== HostRoot) {27 if (isContextProvider(node)) {28 return node.stateNode.__reactInternalMemoizedMergedChildContext;29 }30 const parent = node.return;31 node = parent;32 }33 return node.stateNode.context;34}
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.stopPhaseTimer('load');7 await browser.close();8})();9Playwright Internal API – stopPhaseTimer() method10page.stopPhaseTimer(phaseName)11Example 2: Use stopPhaseTimer() method to stop the phase timer12const { chromium } = require('playwright');13(async () => {14 const browser = await chromium.launch();15 const context = await browser.newContext();16 const page = await context.newPage();17 await page.stopPhaseTimer('load');18 await browser.close();19})();
Using AI Code Generation
1const { Playwright } = require('playwright');2const playwright = new Playwright();3const browser = await playwright.chromium.launch();4const context = await browser.newContext();5const page = await context.newPage();6await page.pause();7await page.stopPhaseTimer('load');8await page.close();9await context.close();10await browser.close();
Using AI Code Generation
1const { Playwright } = require('playwright');2const playwright = new Playwright();3const { chromium } = playwright;4const browser = await chromium.launch();5const context = await browser.newContext();6const page = await context.newPage();7await page.stopPhaseTimer('load');8await page.screenshot({ path: 'example.png' });9await browser.close();10Your name to display (optional):11Your name to display (optional):12Your name to display (optional):
Using AI Code Generation
1const { Playwright } = require('playwright');2const playwright = new Playwright();3const browser = await playwright.chromium.launch();4const page = await browser.newPage();5await page.evaluate(() => {6 Playwright.stopPhaseTimer('page.goto');7});8const { Playwright } = require('playwright');9const playwright = new Playwright();10const browser = await playwright.chromium.launch();11const page = await browser.newPage();12await page.evaluate(() => {13 Playwright.stopPhaseTimer('page.goto');14});15const { Playwright } = require('playwright');16const playwright = new Playwright();17const browser = await playwright.chromium.launch();18const page = await browser.newPage();19await page.evaluate(() => {20 Playwright.stopPhaseTimer('page.goto');21});22const { Playwright } = require('playwright');23const playwright = new Playwright();24const browser = await playwright.chromium.launch();25const page = await browser.newPage();26await page.evaluate(() => {27 Playwright.stopPhaseTimer('page.goto');28});29const { Playwright } = require('playwright');30const playwright = new Playwright();31const browser = await playwright.chromium.launch();32const page = await browser.newPage();33await page.evaluate(() => {34 Playwright.stopPhaseTimer('page.goto');35});36const { Playwright } = require('playwright');37const playwright = new Playwright();38const browser = await playwright.chromium.launch();39const page = await browser.newPage();40await page.evaluate(() => {41 Playwright.stopPhaseTimer('page.goto');42});43const { Playwright }
Using AI Code Generation
1const { chromium } = require('playwright');2const { stopPhaseTimer } = require('playwright/lib/internal/inspectorInstrumentation');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.screenshot({ path: 'example.png' });8 await browser.close();9 stopPhaseTimer('browser');10})();11const { chromium } = require('playwright');12const { stopPhaseTimer } = require('playwright/lib/internal/inspectorInstrumentation');13(async () => {14 const browser = await chromium.launch();15 const context = await browser.newContext();16 const page = await context.newPage();17 await page.screenshot({ path: 'example.png' });18 await browser.close();19 stopPhaseTimer('browser');20})();21const { chromium } = require('playwright');22const { stopPhaseTimer } = require('playwright/lib/internal/inspectorInstrumentation');23(async () => {24 const browser = await chromium.launch();25 const context = await browser.newContext();26 const page = await context.newPage();27 await page.screenshot({ path: 'example.png' });28 await browser.close();29 stopPhaseTimer('browser');30})();31const { chromium } = require('playwright');32const { stopPhaseTimer } = require('playwright/lib/internal/inspectorInstrumentation');33(async () => {34 const browser = await chromium.launch();35 const context = await browser.newContext();36 const page = await context.newPage();37 await page.screenshot({ path: 'example.png' });38 await browser.close();39 stopPhaseTimer('browser');40})();41const { chromium } = require('playwright');42const { stopPhaseTimer } = require('playwright/lib/internal/inspectorInstrumentation');
Using AI Code Generation
1const { Playwright } = require('playwright');2const { chromium } = require('playwright');3const { firefox } = require('playwright');4const { webkit } = require('playwright');5const { devices } = require('playwright');6const { selectors } = require('playwright');7const { types } = require('playwright');8const { createTestFixtures } = require('playwright');9const { expect } = require('playwright');10const { expectType } = require('playwright');11const { skipBrowser } = require('playwright');12const { Playwright } = require('playwright');13const { chromium } = require('playwright');14const { firefox } = require('playwright');15const { webkit } = require('playwright');16const { devices } = require('playwright');17const { selectors } = require('playwright');18const { types } = require('playwright');19const { createTestFixtures } = require('playwright');20const { expect } = require('playwright');21const { expectType } = require('playwright');22const { skipBrowser } = require('playwright');23const { Playwright } = require('playwright');24const { chromium } = require('playwright');25const { firefox } = require('playwright');26const { webkit } = require('playwright');27const { devices } = require('playwright');28const { selectors } = require('playwright');29const { types } = require('playwright');30const { createTestFixtures } = require('playwright');31const { expect } = require('playwright');32const { expectType } = require('playwright');33const { skipBrowser } = require('playwright');34const { Playwright } = require('playwright');35const { chromium } = require('playwright');36const { firefox } = require('playwright');37const { webkit } = require('playwright');38const { devices } = require('playwright');39const { selectors } = require('playwright');40const { types } = require('playwright');41const { createTestFixtures } = require('playwright');42const { expect } = require('playwright');43const { expectType } = require('play
Using AI Code Generation
1const { Playwright } = require('playwright');2const { PlaywrightInternal } = require('playwright/lib/server/playwright.js');3const { BrowserContext } = require('playwright/lib/server/browserContext.js');4const { Page } = require('playwright/lib/server/page.js');5const playwright = Playwright.create();6const playwrightInternal = new PlaywrightInternal(playwright);7const browser = await playwright.chromium.launch();8const context = await browser.newContext();9const page = await context.newPage();10const timer = new PlaywrightInternal.PhaseTimer();11timer.phaseStarted('phase1');12timer.phaseStarted('phase2');13timer.phaseEnded('phase1');14timer.phaseEnded('phase2');15const result = timer.result();16console.log(result);17await browser.close();18{19}20new PlaywrightInternal(playwright: Playwright)21new PhaseTimer()22phaseStarted(phaseName: string)23phaseEnded(phaseName: string)24result(): Object25{26}
Using AI Code Generation
1const { InternalAPI } = require('@playwright/test');2const { test } = require('@playwright/test');3const { chromium } = require('playwright');4test('test', async ({ page }) => {5 const context = await chromium.launch();6 const page = await context.newPage();7 await page.waitForSelector('input[name="q"]');8 await page.fill('input[name="q"]', 'playwright');9 await page.click('input[type="submit"]');10 await page.waitForSelector('text=Playwright');11 await page.click('text=Playwright');12 await page.waitForSelector('text=GitHub - microsoft/playwright: Node.js library to automate');13 await page.click('text=GitHub - microsoft/playwright: Node.js library to automate');14 await page.waitForSelector('a[href="
Using AI Code Generation
1const { _debug } = require('playwright');2const { stopPhaseTimer } = _debug;3(async () => {4 await stopPhaseTimer();5})();6const { _debug } = require('playwright');7const { startPhaseTimer } = _debug;8(async () => {9 await startPhaseTimer();10})();11const { _debug } = require('playwright');12const { getPhaseTimings } = _debug;13(async () => {14 await getPhaseTimings();15})();16const { _debug } = require('playwright');17const { getPhaseTimings } = _debug;18(async () => {19 await getPhaseTimings();20})();21const { _debug } = require('playwright');22const { startPhaseTimer } = _debug;23(async () => {24 await startPhaseTimer();25})();26const { _debug } = require('playwright');27const { stopPhaseTimer } = _debug;28(async () => {29 await stopPhaseTimer();30})();31const { _debug } = require('playwright');32const { getPhaseTimings } = _debug;33(async () => {34 await getPhaseTimings();35})();36const { _debug } = require('playwright');37const { startPhaseTimer } = _debug;38(async () => {39 await startPhaseTimer();40})();41const { _debug } = require('playwright');42const { stopPhaseTimer } = _debug;43(async () => {44 await stopPhaseTimer();45})();46const { _debug } = require('playwright');47const { getPhaseTimings } = _debug;48(async () => {49 await getPhaseTimings();50})();51const { _debug } = require('playwright');52const { startPhaseTimer } = _debug;53(async () => {
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!