microlinkhq / microlinkhq/react-json-view
"Element type is invalid" with vite 8
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 417
- Forks
- 68
- Avg merge
- 4h 22m
- Merged PRs (30d)
- 8
Description
Our project moved to vite 8 and now we're getting react error 130:
Element type is invalid: expected a string (for built-in components) or a class/function
(for composite components) but got: object.
This is with v1.31.12 and this import:
import ReactJson from '@microlink/react-json-view';
There seems to be an interop/export-shape problem with @microlink/react-json-view (UMD/CJS wrapping can make a “default import” resolve to a module object, and React then throws: “got: object”).
We worked around the issue by importing the module namespace and normalizing to the actual component (default or reactJsonView) before rendering:
import * as ReactJsonViewModule from '@microlink/react-json-view';
const ReactJson =
((ReactJsonViewModule as any).default ??
(ReactJsonViewModule as any).reactJsonView ??
ReactJsonViewModule) as React.ComponentType<any>;
After this, <ReactJson ... /> is always a real component at runtime.
Can this change be avoided? Is there something missing in this package?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the reported React error with Vite 8 and the documented default import, then inspect the package's published export shape and build entry points. Done means the normal import resolves to a renderable component without the namespace-normalization workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- build-system, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100