<Link style={{textDecoration: 'none'}} to={{
state: { fromDashboard: true },
pathname:`/Forum/thread/${thread.threadLink}`,
}} >
{thread.title}
</Link>
I encountered an error while using this code snippet on the second line. I find it perplexing since I believed I was adhering to the React Router DOM documentation...
The error message reads: "Type '{ state: { fromDashboard: true; }; pathname: string; }' is not assignable to type 'To'. Object literal may only specify known properties, and 'state' does not exist in type 'Partial'.ts(2322) index.d.ts(70, 5): The expected type comes from property 'to' which is declared here on type 'IntrinsicAttributes & LinkProps & RefAttributes'"
My dependencies include: "react": "^18.2.0", "react-dom": "^18.2.0", "react-router-dom": "^6.8.0"
I attempted switching the order of 'state:'string' and moving it below the pathname declaration, but the issue persisted.
I also tried:
npm uninstall --save-dev @types/react-router npm uninstall --save-dev @types/react-router-dom npm un -D @types/react-router npm un -D @types/react-router-dom npm i -S react@18 react-dom@18