Skip to content
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

fix: revert breaking React 18 changes #913

Merged
merged 1 commit into from
May 31, 2023
Merged

fix: revert breaking React 18 changes #913

merged 1 commit into from
May 31, 2023

Conversation

manzt
Copy link
Member

@manzt manzt commented May 31, 2023

Changes from #898 are breaking to end users who use React 16 or 17 and gosling.embed (e.g., Gos). The peer-dependencies in Gosling allow for react-dom v16/17/18, but only react-dom v18 has react-dom/client. The top-level ReactDOM.render() will eventually be deprecated, but it's totally fine to use for the moment.

This PR reverts use of react-dom/client (and createRoot), which is specific to react-dom v18, for the backward compatible ReactDOM.render.

I'm happy to discuss narrowing support for React versions in Gosling, but the previous changes seemed a bit too restrictive and would likely break many existing Gosling usage for folks who allow for upgrading patches in their dependencies.

Change List

  • Reverts use of react-dom/client to react-dom to avoid breaking change in patch release.

Checklist

  • Ensure the PR works with all demos on the online editor
  • Unit tests added or updated
  • Examples added or updated
  • Documentation updated (e.g., added API functions)
  • Screenshots for visual changes (e.g., new encoding support or UI change on Editor)

@manzt manzt requested a review from sehilyi May 31, 2023 19:29
Copy link
Member

@sehilyi sehilyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I apologize. I overlooked the case of using lower React versions. I will cut the version upon merging this.

Comment on lines 1 to +12
import React from 'react';
import ReactDOM from 'react-dom/client';
import ReactDOM from 'react-dom';
import { BrowserRouter, Route } from 'react-router-dom';
import Editor from './Editor';
import './index.css';
import 'higlass/dist/hglib.css';

const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
root.render(
ReactDOM.render(
<BrowserRouter>
<Route component={Editor} />
</BrowserRouter>
</BrowserRouter>,
document.getElementById('root') as HTMLElement
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also have to be reverted?

Copy link
Member Author

@manzt manzt May 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't have to be, but my thinking was to be consistent in the editor with how we expect most will consume Gosling.js package. When we upgrade react (and it does break in the future), the editor will also break, signaling we need to narrow the react compatibility versions.

In other words, there's no tests in place to ensure gosling-embed.ts works. It would probably be useful to do so, but unifying how we use react in the library in the editor could help surface issues faster.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense. I am happy with the current version.

@manzt manzt merged commit 52bf2f2 into master May 31, 2023
@manzt manzt deleted the manzt/react-18 branch May 31, 2023 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants