TS2322: Type 'Dispatch<SetStateAction<string[]>>' is not assignable to type 'SetStateAction<string[]>'.
Type 'Dispatch<SetStateAction<string[]>>' is not assignable to type '(prevState: string[]) => string[]'.
Type 'void' is not assignable to type 'string[]'.
TS2349: This expression is not callable.
Not all constituents of type 'SetStateAction<string[]>' are callable.
Type 'string[]' has no call signatures.
TS2322: Type 'Dispatch<SetStateAction<string[]>>' is not assignable to type 'SetStateAction<string[]>'.
Type 'Dispatch<SetStateAction<string[]>>' is not assignable to type '(prevState: string[]) => string[]'.
Type 'void' is not assignable to type 'string[]'.
TS2349: This expression is not callable.
Not all constituents of type 'SetStateAction<string[]>' are callable.
Type 'string[]' has no call signatures.
interface IProps {
todoList: string[];
setTodoList: SetStateAction<string[]>;
}
import React, { Dispatch, SetStateAction } from 'react';
interface IProps {
todoList: string[];
setTodoList: Dispatch<SetStateAction<string[]>>;
}
Dispatch
, SetStateAction
을 import 해서 불러왔으며, 만약 위처럼 import 하지 않고 React 만 import 한다면 아래와 같이 사용 할 수 있다.import React from 'react';
interface IProps {
todoList: string[];
setTodoList: React.Dispatch<React.SetStateAction<string[]>>;
}
→ 이것도 React 떼고 쓰다가 cannot find name
에러로 발견했다 ㅎㅎ..!
void
로도 해결이 가능하다.interface IProps {
todoList: string[];
setTodoList: (arg : string[]) => void;
// 이 경우 매개변수의 타입도 함께 설정해야한다.
}