1 | import { isMemo, isFragment } from 'react-is';
|
2 | export function toArray(candidate) {
|
3 | if (candidate === undefined || candidate === false) return [];
|
4 | return Array.isArray(candidate) ? candidate : [candidate];
|
5 | }
|
6 |
|
7 | function shouldConstruct(Component) {
|
8 | const prototype = Component.prototype;
|
9 | return !!(prototype && prototype.isReactComponent);
|
10 | }
|
11 |
|
12 | function isSimpleFunctionComponent(type) {
|
13 | return typeof type === 'function' && !shouldConstruct(type) && type.defaultProps === undefined;
|
14 | }
|
15 | export function isSafeSetRefComponent(component) {
|
16 | if (isFragment(component)) return false;
|
17 | if (isMemo(component)) return isSafeSetRefComponent(component.type);
|
18 | return !isSimpleFunctionComponent(component.type);
|
19 | } |
\ | No newline at end of file |