react速览 崮生的笔记/读书笔记/react/react速览 2020-12-26约 257 字阅读约 1 分钟 崮生的 react 速览ref 选中 dom function TextInputWithFocusButton() { const inputEl = useRef(null); const onButtonClick = () => { // `current` 指向已挂载到 DOM 上的文本输入元素 inputEl.current.focus(); }; return ( <> Focus the input > ); } 嵌入块 获取当前路由的 child (子路由) 选中的哪一个 route typescript const cur = route?.routes?.find((el) => matchPath(location.pathname, el)) 上一篇react下一篇rust