Skip to content
Snippets Groups Projects
Commit 1ab2ce59 authored by Oisin Coveney's avatar Oisin Coveney
Browse files

use shim check for shimming

parent c20874b1
No related branches found
No related tags found
No related merge requests found
import React from "react";
import { useSyncExternalStore } from "use-sync-external-store/shim";
import { getMajorReactVersion } from "metabase/lib/compat/check-version";
// Monkey-patches useSyncExternalStore if we are in React 17,
// where useSyncExternalStore is not available.
// This is used in react-redux v8, until they've dropped the shim in v9.
const reactVersion = getMajorReactVersion();
export const shouldShimExternalStore = () => !("useSyncExternalStore" in React);
if (reactVersion <= 17) {
if (shouldShimExternalStore()) {
React.useSyncExternalStore = useSyncExternalStore;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment