Skip to content

Compatibility with Preact #658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
connor-baer opened this issue Aug 6, 2020 · 6 comments
Closed

Compatibility with Preact #658

connor-baer opened this issue Aug 6, 2020 · 6 comments
Labels
stale 🛠️ tech Changes to the tech stack or infrastructure

Comments

@connor-baer
Copy link
Member

connor-baer commented Aug 6, 2020

Suggested technology

Preact is a fast 3kB alternative to React with the same modern API.

In applications where performance is critical (e.g. the marketing website), switching from React to Preact can decrease the overall bundle size significantly.

We need to investigate whether Circuit UI is compatible with Preact and what we would need to do to support it out of the box. This could be achieved through code changes or documenting the steps that users need to take to make them work together.

Note: Emotion stopped supporting Preact officially but it might be compatible anyway (#658 (comment)).

Alternatives

Preact is in itself an alternative to React, our current UI framework. I'm not aware of other React-compatible, performance-focused libraries.

Potential downsides

Officially supporting Preact might add significant amounts of work to maintain compatibility in the future.

@connor-baer connor-baer added the 🛠️ tech Changes to the tech stack or infrastructure label Aug 6, 2020
@connor-baer connor-baer added this to the v2.x milestone Aug 6, 2020
@connor-baer connor-baer changed the title Support compatibility with Preact [RFC] Support compatibility with Preact Aug 17, 2020
@connor-baer connor-baer added the 📝 RFC Request for comment label Aug 17, 2020
@felixjung
Copy link
Collaborator

This is an important topic. Preact might be what we end up using for the Single Sign On page, eventually. I think Preact X came out after Emotion dropped support. In the upgrade docs for Preact X, they describe how Preact X is fully compatible with the latest version of styled components. Could be that the same is true for emotion, provided a matching tsc or babel config.

Maybe @ForsakenHarmony can share some insights here.

@ForsakenHarmony
Copy link

Yes, when aliasing react to preact X I don't think there are currently any known compatibility issues with emotion

Most compatibility issues are considered bugs, but some special things react does, i.e. preactjs/preact#2852 are ruled out

There are also no plans for concurrent mode right now, but most app don't need it (and the ones that do might be better off doing the performance critical parts outside of react)

@connor-baer connor-baer modified the milestones: v2.x, v3.x Jun 29, 2021
@felixjung
Copy link
Collaborator

When working with forms, I ran into an issue with the defaultValue prop React supports. This prop is primarily used to populate the initial value on uncontrolled inputs.

The expected behavior for the defaultValue prop is that

  • the initial value of a form element should match the value of defaultValue,
  • changing it won't trigger a re-render,
  • it shouldn't cause the value prop to get set.

Working with preact-compat it seems that the implementation there doesn't meet the above expected behavior. preact-compat sets an elements value prop to the value of defaultValue. Changing defaultValue then also updates the component. In that sense defaultValue behaves like value.

I found an open PR dealing with some parts of the problem.

My conclusion is that, currently, you cannot create an uncrontrolled input with a defaultValue when using preact-compat. This is fine for our use case in identity, a select component, but might cause issues with inputs where you then have to start managing the state with debouncing etc.

@ForsakenHarmony
Copy link

@felixjung preact-compat or preact/compat?

preact-compat is for preact < 10

@connor-baer connor-baer removed this from the v3.x milestone Jan 7, 2022
@connor-baer connor-baer changed the title [RFC] Support compatibility with Preact Compatibility with Preact Jan 7, 2022
@connor-baer connor-baer removed the 📝 RFC Request for comment label Jan 7, 2022
@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Add a comment explaining why the issue is still relevant to prevent it from being closed.

@github-actions github-actions bot added the stale label May 23, 2023
@connor-baer
Copy link
Member Author

Apart from the general compatibility issues between React and Preact that @felixjung mentioned above (which might have been fixed by now), there doesn't seem to be anything further we can do inside Circuit UI.

We have plans to replace Emotion.js with a build-time styling solution which should ensure future compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale 🛠️ tech Changes to the tech stack or infrastructure
Projects
None yet
Development

No branches or pull requests

3 participants