Last active
December 15, 2020 02:32
-
-
Save softmarshmallow/1e0cd06d9be842378e6b20411b0a37fe to your computer and use it in GitHub Desktop.
usage of recoil + konva
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
import React from "react"; | |
import { useRecoilBridgeAcrossReactRoots_UNSTABLE, useRecoilState } from "recoil"; | |
function accessGlobalStateUnderKonvaCanvas(){ | |
// https://github.com/konvajs/react-konva/issues/533 | |
const RecoilBridge = useRecoilBridgeAcrossReactRoots_UNSTABLE() | |
return ( | |
<Stage> | |
<RecoilBridge> | |
<Rect onclick={e=>{updateSomeGlobalState(e.target.id)}}/> | |
</RecoilBridge> | |
</Stage> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment