Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Framer X WindowResizeListener
import { Override, Data } from "framer"
import * as React from "react"
const initialSize = document.body.getBoundingClientRect()
const preview = Data({ width: initialSize.width, height: initialSize.height })
export function WindowResizeListener(): Override {
React.useEffect(function() {
function updateViewSize() {
const rect = document.body.getBoundingClientRect()
preview.width = rect.width
preview.height = rect.height
window.addEventListener("resize", updateViewSize)
return function removeListener() {
window.removeEventListener("resize", updateViewSize)
return {
width: preview.width,
height: preview.height,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment