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 Warning: ReactDOM.render is no longer supported in React 18 for @graphql-yoga/graphiql #3418

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/graphiql/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
<div id="root"></div>

<script type="module">
import * as yogaGraphiQL from './src/bundle.tsx';
import { renderYogaGraphiQL } from './src/bundle.tsx';

const container = window.document.querySelector('#root');
yogaGraphiQL.renderYogaGraphiQL(container, {
const container = document.getElementById('root');
renderYogaGraphiQL(container, {
endpoint: '/graphql',
});
</script>
Expand Down
10 changes: 5 additions & 5 deletions packages/graphiql/src/YogaGraphiQL.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { explorerPlugin } from '@graphiql/plugin-explorer';
import '@graphiql/plugin-explorer/dist/style.css';
import React, { useMemo, useState } from 'react';
import { GraphiQL, GraphiQLInterface, GraphiQLProps, GraphiQLProvider } from 'graphiql';
import { DocumentNode, Kind, parse } from 'graphql';
import { explorerPlugin } from '@graphiql/plugin-explorer';
import { Fetcher, FetcherOpts, FetcherParams } from '@graphiql/toolkit';
import { LoadFromUrlOptions, SubscriptionProtocol, UrlLoader } from '@graphql-tools/url-loader';
import 'graphiql/graphiql.css';
import { DocumentNode, Kind, parse } from 'graphql';
import 'json-bigint-patch';
import React, { useMemo, useState } from 'react';
import { useUrlSearchParams } from 'use-url-search-params';
import { YogaLogo } from './YogaLogo';
import 'graphiql/graphiql.css';
import '@graphiql/plugin-explorer/dist/style.css';
import './styles.css';

const getOperationWithFragments = (
Expand Down
5 changes: 3 additions & 2 deletions packages/graphiql/src/bundle.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { createRoot } from 'react-dom/client';
import { YogaGraphiQL, YogaGraphiQLProps } from './YogaGraphiQL.js';

export function renderYogaGraphiQL(element: Element, opts?: YogaGraphiQLProps) {
ReactDOM.render(<YogaGraphiQL {...opts} />, element);
const root = createRoot(element);
root.render(<YogaGraphiQL {...opts} />);
}

globalThis.React = React;
Loading