import React, { createContext, PropsWithChildren, useContext, useState } from 'react' type ContextValue = { width: number, setWidth: (nextWidth: number) => void } const context = createContext({ width: 0, setWidth: () => undefined }) export function useScrollbarWidth() { return useContext(context) } export default function ScrollbarWidthProvider({ children }: PropsWithChildren<{}>) { const [width, setWidth] = useState(0) return ( {children} ) }