Failed to execute 'requestAnimationFrame' on 'Window' when storing zoom level in state
See original GitHub issueI get this error when i use the onZoomChange to store the current zoom level in my components state.
this is an extract of my code, if i comment out the setZoom()
statement below it works fine again.
....
const [zoom, setZoom] = useState<number>();
const zoomChange = ({ scale }) => {
console.log('zoom', scale);
setZoom(scale);
};
return (
<SelectionProvider>
<TransformWrapper {...opts} onZoomChange={zoomChange}>
{({ zoomIn, zoomOut, resetTransform }) => (
<>
<TransformComponent>
<div className="graphView__container">
<Graph
graph={graph}
bounds={graphBounds}
zoom={zoom || 1}
/>
</div>
</TransformComponent>
<ToolButtons
zoomIn={zoomIn}
zoomOut={zoomOut}
resetTransform={resetTransform}
/>
</>
)}
</TransformWrapper>
);
TypeError: Failed to execute 'requestAnimationFrame' on 'Window': The callback provided as parameter 1 is not a function.
animation
src/store/animations/index.ts:35
32 | this.animation = null;
33 | } else {
34 | callback(step);
> 35 | requestAnimationFrame(this.animation);
36 | ^ }
37 | };
38 |
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:8
Top Results From Across the Web
The callback provided as parameter 1 is not a function. ...
Failed to execute 'requestAnimationFrame' on 'Window': The callback provided as parameter 1 is not a function.
Read more >requestAnimationFrame and PAUSING Animation - YouTube
In NativeScript 6.5 a new function has been added that we've been waiting for - requestAnimationFrame. In this NativeScript tutorial, ...
Read more >Leaflet 1.7 documentation
Returns the minimum zoom level of the map (if set in the minZoom option of the map or of any layers), or 0...
Read more >JSDoc: Source: fabric.js
createHTMLDocument(''); } fabric.window = window; } else { // assume we're running under node.js when document/window are not present var jsdom ...
Read more >NW.js Documentation
win.maximize(). Maximize the window on GTK and Windows, and zoom the window on Mac OS X. ... Restore window to previous state after...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I needed to toggle between zoomIn/reset mode on
doubleClick
depending on the zoom state. I was getting the same error, so what I did is to wait for the animation to finish (which defaults to 200ms) before setting the state, usingsetTimeout
@edwinlimlx a quick workaround that worked for me was to use function child (or whatever it’s called in react world)