Skip to content

Commit

Permalink
fix: prevent infinite loop when using plugins with some frameworks
Browse files Browse the repository at this point in the history
Testing remix with the emotion-cache-plugin was resulting in an infinite loop due to the way that plugins and overrides were defaulted.
  • Loading branch information
chrisvxd committed Aug 31, 2024
1 parent 041c4a8 commit 3870871
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions packages/core/components/Puck/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ export function Puck<UserConfig extends Config = Config>({
onPublish,
onAction,
permissions = {},
plugins = [],
overrides = {},
plugins,
overrides,
renderHeader,
renderHeaderActions,
headerTitle,
Expand Down Expand Up @@ -393,7 +393,7 @@ export function Puck<UserConfig extends Config = Config>({
config,
componentState,
resolveData,
plugins,
plugins: plugins || [],
overrides: loadedOverrides,
history,
viewports,
Expand Down
6 changes: 3 additions & 3 deletions packages/core/lib/load-overrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ export const loadOverrides = ({
overrides,
plugins,
}: {
overrides: Partial<Overrides>;
plugins: Plugin[];
overrides?: Partial<Overrides>;
plugins?: Plugin[];
}) => {
const collected = { ...overrides };

plugins.forEach((plugin) => {
plugins?.forEach((plugin) => {
Object.keys(plugin.overrides).forEach((overridesType) => {
if (overridesType === "fieldTypes") {
const fieldTypes = plugin.overrides.fieldTypes!;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/lib/use-loaded-overrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export const useLoadedOverrides = ({
overrides,
plugins,
}: {
overrides: Partial<Overrides>;
plugins: Plugin[];
overrides?: Partial<Overrides>;
plugins?: Plugin[];
}) => {
return useMemo(() => {
return loadOverrides({ overrides, plugins });
Expand Down

0 comments on commit 3870871

Please sign in to comment.