Closed amirhosein-rafeie closed 2 years ago
@amirhosein-rafeie There is no ref prop on components. use onLoad prop function to receive an instance in arguments.
ref is old way to receive instance used by unmaintained npm react-google-maps-api@9.4.5
library
This library never had a ref
property!
Issue template
If you want to ask question, please ask it in Github Discussions, Spectrum.chat or Slack channel
Please do not post unformatted code into issues, and please do not ask questions. Only real issues, PR's or feature requests are allowed. Minimal reproduction in codesandbox.io is required.
Please provide an explanation of the issue
Your Environment
os: windows
node --16.13.0
react version 17.0.2
@react-google-maps/api version 2.8.1
How does it behave?
we don't have acccess to setDrawingModes by ref
How should it behave correctly?
we should be able to change drawingModes by Ref
Basic implementation of incorrect behavior in codesandbox.com
const drawingRef = useRef();
<DrawingManager ref={drawingRef} drawingMode="polygon" onLoad={(e) => console.log(e)} options={{ drawingControl: true, drawingControlOptions: { drawingModes: ["polygon"], }, polygonOptions: { editable: true, draggable: true, strokeColor: "red", strokeWeight: 2, }, }} /> <button onClick={()=>{ drawingRef.current.setDrawingMode(null); //it doesnt work }}>Change Mode