I have this following code the idea is I want to later concat those 2 stings together , which led to this logic, any idea how to handle updating this state ? the state is updated using a handchange function. but it is giving me an error A spread argument must either have a tuple type or be passed to a rest parameter. maybe my whole approach to updating the state in wrong.
const [link, SetLink] = useState<{ site: string[] }>({ site: ['https://www.somesite.com/', ''] });
SetLink(...link.site[1], (link.site[1] = target.value));
CodePudding user response:
setLink(prevState => ({ site: [prevState.site[0], target.value] }))