I am passing a setState as a prop from a parent component to modify the state on a child component of that parent, on typescript when creating a interface, what is the type of setState?
function App() {
const [links, setLinks] = useState();
return (
<div className='App'>
<Sidebar setLinks={setLinks} />
<Main />
</div>
);
}
on child:
interface SidebarProps {
setLinks: ??????;
}
const Sidebar: React.FC<SidebarProps> = ({ setLinks }) => {
return (
<div style={sidebar}>
<button onClick={() => setLinks('1')}>pic1</button>
<button onClick={() => setLinks('1')}>pic2</button>
</div>
);
};
(link: string) => void;Appcomponent you've called itsetLinks, but in theSidebaryou're usingsetLinkDispatch<SetStateAction<undefined>>, whichDispatchandSetStateActioncan be imported fromreact