Skip to content

Commit

Permalink
fix: don't throw warning when user is correctly specifying root props
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvxd committed May 12, 2024
1 parent b1c40c6 commit 46aa8ff
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions packages/core/components/Puck/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,17 @@ export function Puck<UserConfig extends Config = Config>({
}

// DEPRECATED
const rootProps = initialData?.root?.props || initialData.root || {};
if (
Object.keys(initialData?.root || {}).length > 0 &&
!initialData?.root?.props
) {
console.error(
"Warning: Defining props on `root` is deprecated. Please use `root.props`, or republish this page to migrate automatically."
);
}

// Deprecated
const rootProps = initialData?.root?.props || initialData?.root || {};

const defaultedRootProps = {
...config.root?.defaultProps,
Expand All @@ -158,7 +168,7 @@ export function Puck<UserConfig extends Config = Config>({
...defaultAppState,
data: {
...initialData,
root: defaultedRootProps,
root: { ...initialData?.root, props: defaultedRootProps },
content: initialData.content || [],
},
ui: {
Expand Down Expand Up @@ -232,15 +242,6 @@ export function Puck<UserConfig extends Config = Config>({
// DEPRECATED
const rootProps = data.root.props || data.root;

// DEPRECATED
useEffect(() => {
if (Object.keys(data.root).length > 0 && !data.root.props) {
console.error(
"Warning: Defining props on `root` is deprecated. Please use `root.props`. This will be a breaking change in a future release."
);
}
}, []);

const toggleSidebars = useCallback(
(sidebar: "left" | "right") => {
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
Expand Down

0 comments on commit 46aa8ff

Please sign in to comment.