Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Cannot find name 'Dispatch'.ts(2304) and 'SetStateAction'.ts(2304)

I’m trying to pass my setState function to a child component, but when I pass it down, I get two typescript errors: Cannot find name ‘Dispatch’.ts(2304) and Cannot find name ‘SetStateAction’.ts(2304)

Does anyone know how to fix this?

// page.tsx
import { useState } from 'react';

export default function Page() {
  const [jobs, setJobs] = useState([]);

  return (
    <JobMenubar jobs={jobs} setJobs={setJobs} />
  )
}
// JobMenubar.tsx

type Props = {
  jobs: string[]
  setJobs: Dispatch<SetStateAction<never[]>> // Cannot find name 'Dispatch'.ts(2304) and Cannot find name 'SetStateAction'.ts(2304)
}

export default function JobMenubar({ filteredJobs, setFilteredJobs } : Props) {
  return (
    // ...
  )
}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

I use Dispatch from my provider.

export type ObjectSend = {
idDocumento: Guid;
Url: string;
Name: string;

};

import {
SetStateAction,
Dispatch } from "react";

setChecked: Dispatch<SetStateAction<ObjectSend[]>>;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading