Created
March 4, 2019 21:30
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Source