javascript - Type '`${string}`' is not assignable to type 'ExternalPathString'.ts - Stack Overfl

admin2025-04-26  4

I am getting above mentioned error in heading on this code snippet

<Link      
     href={{          
     pathname: `/${String(service.name.toLowerCase())}`,      
     }} 
>

Even though service.name is already a string but i also added String type but still expo not considering this as same type ExternalPathString to this.

I am getting above mentioned error in heading on this code snippet

<Link      
     href={{          
     pathname: `/${String(service.name.toLowerCase())}`,      
     }} 
>

Even though service.name is already a string but i also added String type but still expo not considering this as same type ExternalPathString to this.

Share Improve this question edited Apr 1 at 19:30 Christoph Rackwitz 16k5 gold badges39 silver badges51 bronze badges asked Jan 12 at 17:32 Vijay JangalVijay Jangal 112 bronze badges 1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Bot Commented Jan 13 at 23:19
Add a comment  | 

1 Answer 1

Reset to default 0

According to the docs for dynamic routes, it shows you should add [name] and then reference what [name] should be in a separate property called params.

Something like below should work, if it does not please let me know and I'll try and help you from there.

<Link
  href={{
    pathname: '/[serivceName]',
    params: { serviceName: servie.name.toLowerCase() },
  }}>
    {/* Content here */}
</Link>

I think you do need a file called the name of your service or [serviceName].(jsx/tsx) for this to work, but I think you may have already done that.

转载请注明原文地址:http://www.anycun.com/QandA/1745676540a91070.html