Skip to content

Commit

Permalink
πŸ›
Browse files Browse the repository at this point in the history
  • Loading branch information
zbeyens committed Sep 22, 2023
1 parent 30d54a9 commit 7210e35
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions apps/www/src/registry/default/example/playground-demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,17 @@ export const usePlaygroundPlugins = ({

// reset editor when initialValue changes
export const useInitialValueVersion = (initialValue: Value) => {
const enabled = settingsStore.use.checkedPlugins();
const [version, setVersion] = useState(1);
const prevEnabled = useRef(enabled);
const prevInitialValueRef = useRef(initialValue);

useEffect(() => {
if (enabled === prevEnabled.current) return;
prevEnabled.current = enabled;
setVersion((v) => v + 1);
}, [enabled]);

useEffect(() => {
if (initialValue === prevInitialValueRef.current) return;
prevInitialValueRef.current = initialValue;
Expand Down

0 comments on commit 7210e35

Please sign in to comment.