Skip to content

Commit

Permalink
fix: ensure hooks can always be used within render functions
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvxd committed Sep 18, 2023
1 parent b89feef commit cbf8e8e
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions packages/core/components/Puck/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,14 @@ export function Puck({
id="puck-drop-zone"
>
{data.content.map((item, i) => {
const Render = config.components[item.type]
? config.components[item.type].render
: () => (
<div style={{ padding: 48, textAlign: "center" }}>
No configuration for {item.type}
</div>
);

return (
<DraggableComponent
key={item.props.id}
Expand Down Expand Up @@ -411,19 +419,11 @@ export function Puck({
}}
>
<div style={{ zoom: 0.75 }}>
{config.components[item.type] ? (
config.components[item.type].render({
...config.components[item.type].defaultProps,
...item.props,
editMode: true,
})
) : (
<div
style={{ padding: 48, textAlign: "center" }}
>
No configuration for {item.type}
</div>
)}
<Render
{...config.components[item.type]?.defaultProps}
{...item.props}
editMode={true}
/>
</div>
</DraggableComponent>
);
Expand Down

0 comments on commit cbf8e8e

Please sign in to comment.