I'm facing an issue while attempting to transfer an array of strings from one page to another in Next.js using
<Link href={{ pathname: "/model", query: data }}>
. The problem arises when the query
parameter is red underlined:
Type 'string[]' is not assignable to type 'string | ParsedUrlQueryInput | null | undefined'.
Type 'string[]' is not assignable to type 'ParsedUrlQueryInput'.
Index signature for type 'string' is missing in type 'string[]'.ts(2322)
The requirement is just to pass the data
from one page to a button component and then to another page, without needing global access. Should I resolve this error by utilizing useContext
? Or should I consider converting the string array into a single string using array.toString()
, and then back into an array? Any suggestions would be greatly appreciated.