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

Function isSimpleObject

packages/shared/ReactSerializationErrors.js:66–90  ·  view source on GitHub ↗
(object: any)

Source from the content-addressed store, hash-verified

64}
65
66export function isSimpleObject(object: any): boolean {
67 if (!isObjectPrototype(getPrototypeOf(object))) {
68 return false;
69 }
70 const names = Object.getOwnPropertyNames(object);
71 for (let i = 0; i < names.length; i++) {
72 const descriptor = Object.getOwnPropertyDescriptor(object, names[i]);
73 if (!descriptor) {
74 return false;
75 }
76 if (!descriptor.enumerable) {
77 if (
78 (names[i] === 'key' || names[i] === 'ref') &&
79 typeof descriptor.get === 'function'
80 ) {
81 // React adds key and ref getters to props objects to issue warnings.
82 // Those getters will not be transferred to the client, but that's ok,
83 // so we'll special case them.
84 continue;
85 }
86 return false;
87 }
88 }
89 return true;
90}
91
92export function objectName(object: mixed): string {
93 // $FlowFixMe[method-unbinding]

Callers 2

resolveToJSONFunction · 0.90
renderModelDestructiveFunction · 0.90

Calls 2

isObjectPrototypeFunction · 0.85
getPrototypeOfFunction · 0.50

Tested by

no test coverage detected