Next.js Discord

Discord Forum

Lesson 11 - Error from Typescript - string not assignable to RouteImpl<`${string}?${string}`>'

Unanswered
American black bear posted this in #help-forum
Open in Discord
American black bearOP
In Lesson 11 - search and Pagination () I am stuck and don't know how to suceed.
I get the following Typescript-error in VS-Code
Argument of type '${string}?${string}' is not assignable to parameter of type 'RouteImpl<${string}?${string}>'.ts(2345)

my Code looks like:

export default function Search({ placeholder }: { placeholder: string }) {
const searchParams = useSearchParams();
const pathname = usePathname();
const { replace } = useRouter();

function handleSearch(term: string) {
const params = new URLSearchParams(searchParams);
console.log(term);
if (term) {
params.set('query', term);
} else {
params.delete('query');
}
replace(${pathname}?${params.toString()});
}

return (...)
}

0 Replies