- state
const [name, setName] = useState("aaa");
name.substring(0, 1).toUpperCase() + name.substring(1);
setName("bbb");
const [name, setName] = useState<string>("aaa");
- todo
const myText = useRef(null)
console.log((myText.current as HTMLInputElement).value)
const [list, setList] = useState([])
setList([…list, (myText.current as HTMLInputElement).value]) - props
<Child name="aaa" />;
interface IProps {
name: string;
}
function Child(props: IProps) {
return <div>child</div>;
}
const Child: React.FC<IProps> = (props) => {};
- drawer
const [isShow, setIsShow] = useState(true)
<Navbar cb={()=>{
console.log("111")
setIsShow(!isShow)
}}/>
{isShow && <Sidebar />}
interface IProps {
title?: string,
cb: ()=>void
}
function Navbar(props: IProps) {
props.cb()
}
function Sidebar(props: IProps) {
}