React useState 第二个参数的 Typescript 类型

Typescript Type of React useState second parameter

我正在尝试在我的 React javascript 项目中应用打字稿

我使用 createContext() 来传递 useState() 参数

并应用打字稿,他因 createContext() 中缺少第一个值而大发雷霆

我也不确定我应该为 'setIsOpen'

输入什么类型

希望得到你的帮助,如果你有任何答案...

我在下面留下我的代码截图enter image description here

export const SmartAccordion = ({children}:SmartAccordionProps) => {
  const [isOpen, setIsOpen] = useState(false);

  const value = {
    isOpen,
    setIsOpen
  };

  return (
    <AccordionContext.Provider value={value}>
      <S.Wrapper>{children}</S.Wrapper>
    </AccordionContext.Provider>
  );
};

type AccordionContextType = {
  isOpen: boolean;
  setIsOpen: any;
}


const AccordionContext = createContext();
const useAccordionContext = () => useContext(AccordionContext);

export const SmartAccordionHeader = ({children, className}:SmartAccordionHeaderProps) => {
  const { isOpen, setIsOpen } = useAccordionContext();

  return (
    <S.HeaderWrapper
      onClick={() => setIsOpen(!isOpen)}
      className={className}
    >
      {children}
    </S.HeaderWrapper>
  );
};

React.Dispatch<React.SetStateAction<boolean>>