seek-oss / playroom

Design with JSX, powered by your own component library.
MIT License
4.45k stars 183 forks source link

fix: Add support for React 18 #265

Closed michaeltaranto closed 1 year ago

michaeltaranto commented 1 year ago

Upgrade to support using React 18, while also maintaining backwards compatibility and handling React 17.

Key Changes

React Render API

The approach was heavily inspired by the approach used by Storybook, while avoiding the need to add config to control the version. Playroom decides which version of the render API to use based on the version of react-dom it resolves.

Code editor

The react-codemirror2 editor is unmaintained and not compatible with React 18 (using legacy APIs and not throwing the peer dependency warning). As it is just a thin react wrapper with no additional dependencies, and given the legacy lifecycle hooks still work, we opted to embed a copy while we investigate a Codemirror 6 migration separately.

As part of bringing it in there were some minor modifications:

Extras

Use @ts-expect-error declaration instead of @ts-ignore and fix handful of issues where types were available.


Closes https://github.com/seek-oss/playroom/issues/261