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

Function warnNoop

packages/react-server/src/ReactFizzClassComponent.js:81–103  ·  view source on GitHub ↗
(
  publicInstance: component(...props: any),
  callerName: string,
)

Source from the content-addressed store, hash-verified

79}
80
81function warnNoop(
82 publicInstance: component(...props: any),
83 callerName: string,
84) {
85 if (__DEV__) {
86 const constructor = publicInstance.constructor;
87 const componentName =
88 (constructor && getComponentNameFromType(constructor)) || 'ReactClass';
89 const warningKey = componentName + '.' + callerName;
90 if (didWarnAboutNoopUpdateForComponent[warningKey]) {
91 return;
92 }
93
94 console.error(
95 'Can only update a mounting component. ' +
96 'This usually means you called %s() outside componentWillMount() on the server. ' +
97 'This is a no-op.\n\nPlease check the code for the %s component.',
98 callerName,
99 componentName,
100 );
101 didWarnAboutNoopUpdateForComponent[warningKey] = true;
102 }
103}
104
105type InternalInstance = {
106 queue: null | Array<Object>,

Callers 2

enqueueSetStateFunction · 0.70
enqueueForceUpdateFunction · 0.70

Calls 2

getComponentNameFromTypeFunction · 0.85
errorMethod · 0.65

Tested by

no test coverage detected