Skip to content

Commit

Permalink
Hoist react-merge-refs due to dist issues
Browse files Browse the repository at this point in the history
  • Loading branch information
KetanReddy committed Mar 27, 2024
1 parent c92fc68 commit 7740075
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 20 deletions.
10 changes: 5 additions & 5 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions language/dsl/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ js_pipeline(
"//:node_modules/globby",
"//:node_modules/jsonc-parser",
"//:node_modules/mkdirp",
"//:node_modules/react-flatten-children",
"//:node_modules/react-json-reconciler",
"//:node_modules/react-merge-refs",
"//:node_modules/source-map-js",
"//:node_modules/tapable-ts",
"//:node_modules/ts-node",
Expand Down
2 changes: 1 addition & 1 deletion language/dsl/src/components.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from "react";
import type { ObjectNode, PropertyNode } from "react-json-reconciler";
import { mergeRefs } from "react-merge-refs";
import type { View as ViewType } from "@player-ui/types";
import type { PlayerApplicability, WithChildren } from "./types";
import {
Expand All @@ -16,6 +15,7 @@ import {
toJsonElement,
toJsonProperties,
flattenChildren,
mergeRefs,
} from "./utils";

export type AssetProps = PlayerApplicability & {
Expand Down
18 changes: 18 additions & 0 deletions language/dsl/src/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,24 @@ export function flattenChildren(children: React.ReactNode): ReactChildArray {
return flatChildren;
}, []);
}
/**
* Hoisted from https://github.com/gregberge/react-merge-refs/blob/main/src/index.tsx
* Published packages are ESM only or have bad esm distributions causing issues when
* used in an esm environment
*/
export function mergeRefs<T = any>(
refs: Array<React.MutableRefObject<T> | React.LegacyRef<T> | undefined | null>
): React.RefCallback<T> {
return (value) => {
refs.forEach((ref) => {
if (typeof ref === "function") {
ref(value);

Check warning on line 160 in language/dsl/src/utils.tsx

View check run for this annotation

Codecov / codecov/patch

language/dsl/src/utils.tsx#L160

Added line #L160 was not covered by tests
} else if (ref != null) {
(ref as React.MutableRefObject<T | null>).current = value;
}
});
};
}

/** Generates object reference properties from the provided object */
export function getObjectReferences<
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,8 @@
"react-dom": "^18.2.0",
"react-error-boundary": "^4.0.12",
"react-flame-graph": "^1.4.0",
"react-flatten-children": "^1.1.2",
"react-icons": "^5.0.1",
"react-json-reconciler": "^2.0.0",
"react-merge-refs": "^2.1.1",
"react-redux": "^7.2.6",
"react-split": "^2.0.14",
"react-syntax-highlighter": "^15.4.5",
Expand Down
10 changes: 0 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7740075

Please sign in to comment.