Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save softmarshmallow/1e0cd06d9be842378e6b20411b0a37fe to your computer and use it in GitHub Desktop.
Save softmarshmallow/1e0cd06d9be842378e6b20411b0a37fe to your computer and use it in GitHub Desktop.
usage of recoil + konva
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