How to rerender when refs change
问题 Code: import DrawControl from "react-mapbox-gl-draw"; export default function MapboxGLMap() { let drawControl = null return( <DrawControl ref={DrawControl => {drawControl = DrawControl}}/> ) } I want to load data when the drawControl not null. I check the document that may use callback ref. So, how do I listen the drawControl changes and load data? 回答1: If you want to trigger a re-render after the ref changes, you must use useState instead of useRef . Only that way can you ensure that the