Commit 4652bd0
authored
fix: avoid relying on
### What
Remove references to the `.name` property in the logic for detecting
react components. Instead just rely on `typeof` and `length`.
### Why
Don't use the presence/absence of function names to detect react
components or to distinguish client vs server components.
minifiers generally do not preserve function names. e.g. in swc
[`keepFnNames` is false by
default](https://swc.rs/docs/configuration/minification#:~:text=with%20terser.-,keepFnNames,-%2C%20Defaults%20to%20false).
A recent
[PR](vercel/next.js@ba22704)
in Next.js optimized the representation of esm exports which meant that
many `export function Foo` declarations would loose their names. This
broke users of payloadcms since now server props were no longer
propagated to their components due to the check
[here](https://github.com/payloadcms/payload/blob/c2300059a67a505e0483a2004bc294d8c9d7c463/packages/ui/src/elements/withMergedProps/index.tsx#L43).Function.prototype.name to detect react components (#13931)1 parent 71c684e commit 4652bd0
1 file changed
Lines changed: 3 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
| 8 | + | |
20 | 9 | | |
21 | 10 | | |
22 | 11 | | |
23 | 12 | | |
24 | 13 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 14 | + | |
29 | 15 | | |
30 | 16 | | |
31 | 17 | | |
32 | 18 | | |
33 | 19 | | |
34 | | - | |
| 20 | + | |
35 | 21 | | |
0 commit comments