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

Function defineKeyPropWarningGetter

packages/react/src/jsx/ReactJSXElement.js:112–132  ·  view source on GitHub ↗
(props, displayName)

Source from the content-addressed store, hash-verified

110}
111
112function defineKeyPropWarningGetter(props, displayName) {
113 if (__DEV__) {
114 const warnAboutAccessingKey = function () {
115 if (!specialPropKeyWarningShown) {
116 specialPropKeyWarningShown = true;
117 console.error(
118 '%s: `key` is not a prop. Trying to access it will result ' +
119 'in `undefined` being returned. If you need to access the same ' +
120 'value within the child component, you should pass it as a different ' +
121 'prop. (https://react.dev/link/special-props)',
122 displayName,
123 );
124 }
125 };
126 warnAboutAccessingKey.isReactWarning = true;
127 Object.defineProperty(props, 'key', {
128 get: warnAboutAccessingKey,
129 configurable: true,
130 });
131 }
132}
133
134function elementRefGetterWithDeprecationWarning() {
135 if (__DEV__) {

Callers 2

jsxDEVImplFunction · 0.70
createElementFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected