I need to pass props inside the Link react Router to another component, but I can't due to the interface or type declarations that I don't understand. I've being searching around and I can't find anything to this problem (Typescript).
Here is the code of my component:
const ImageGallery = () => {
interface passProps {
backUrl?: string
}
const backUrl = '/some/other/value';
return (
<Gallery>
{images.map((x, i) => (
<Link key={x} to={{ pathname: 'page', query: { backUrl } }}>
...
and here is the error:
(property) backUrl: string
Type '{ pathname: string; query: { backUrl: string; }; }' is not assignable to type 'LocationDescriptor<unknown> | ((location: Location<unknown>) => LocationDescriptor<unknown>)'.
Object literal may only specify known properties, and 'query' does not exist in type 'LocationDescriptorObject<unknown> | ((location: Location<unknown>) => LocationDescriptor<unknown>)'.ts(2322