import { useRef } from '@wordpress/element';

import {
  createDesignStore,
  DesignContext,
} from '@components/DesignPanel/DesignStore';

type DesignProviderProps = {
  children: React.ReactNode;
};

export const DesignProvider = ({ children }: DesignProviderProps) => {
  const store = useRef(createDesignStore()).current;
  return (
    <DesignContext.Provider value={store}>{children}</DesignContext.Provider>
  );
};

export default DesignProvider;
