You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To get it working, you need to wrap your app in EnvironmentProvider and call the useEnvironment hook anywhere in your app to get access to the correct window and document.
import{EnvironmentProvider}from"@chakra-ui/react-env"// in your AppconstApp=({ children })=>{return<EnvironmentProvider>{children}</EnvironmentProvider>}// read the environmentconstWindowSize=()=>{const{ window }=useEnvironment()return(<pre>{JSON.stringify({w: window.innerWidth,h: window.innerHeight,})}</pre>)}
If you wrap specific aspects of your app within an iframe, you'll need to wrap the content in the iframe in EnvironmentProvider to provide the correct window and document to its content.
// in your appconstEmbeddedIFrame=()=>{return(<Frame><EnvironmentProvider><WindowSize/></EnvironmentProvider></Frame>)}
The text was updated successfully, but these errors were encountered:
https://github.com/chakra-ui/chakra-ui/tree/main/packages/env
Usage
To get it working, you need to wrap your app in
EnvironmentProvider
and call theuseEnvironment
hook anywhere in your app to get access to the correctwindow
anddocument
.If you wrap specific aspects of your app within an
iframe
, you'll need to wrap the content in the iframe inEnvironmentProvider
to provide the correctwindow
anddocument
to its content.The text was updated successfully, but these errors were encountered: