Skip to content

Commit

Permalink
Make external settings optional
Browse files Browse the repository at this point in the history
Signed-off-by: Zvonimir Fras <[email protected]>
  • Loading branch information
zvonimirfras committed Feb 9, 2024
1 parent b81bbb9 commit 4429b18
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions sdk/react/src/lib/components/settings-context-pane.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect, useState } from 'react';
import {
Button,
Checkbox,
Expand Down Expand Up @@ -162,12 +162,14 @@ const throttledSetFragment = throttle((fragment: any) => proxySetFragment(fragme
export const SettingsContextPane = ({
fragment,
setFragment,
settings,
setSettings,
settings: externalSettings,
setSettings: setExternalSettings,
styleClasses,
customComponentsCollections
}: any) => {
const selectedComponent = getSelectedComponent(fragment);
const [settings, setSettings] = useState(externalSettings || {} as any);

const updateContextPaneSettings = (s: any) => {
setSettings({
...settings,
Expand Down Expand Up @@ -196,6 +198,16 @@ export const SettingsContextPane = ({

proxySetFragment = setFragment;

useEffect(() => {
setSettings(externalSettings);
}, [externalSettings]);

useEffect(() => {
if (setExternalSettings) {
setExternalSettings(settings);
}
}, [settings]);

return (
<div className={cx(styleContextPaneStyle, 'context-pane-content')}>
{
Expand Down

0 comments on commit 4429b18

Please sign in to comment.