Skip to content

Instantly share code, notes, and snippets.

@davo
Created March 4, 2019 21:30
Show Gist options
  • Save davo/f8d379bc177d40a1060522f6f0a8d604 to your computer and use it in GitHub Desktop.
Save davo/f8d379bc177d40a1060522f6f0a8d604 to your computer and use it in GitHub Desktop.
Framer X Check if component is on Canvas or Preview Window (via @steveruizok)
const isCanvasOrPreview = (source: any) => {
const searchLoop: (node: any) => 'canvas' | 'preview' = node => {
if (!node) return 'canvas'
if (node.key === 'preview') return 'preview'
return searchLoop(node._debugOwner)
}
return searchLoop(source._reactInternalFiber)
}
@davo
Copy link
Author

davo commented Mar 4, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment