Created
January 16, 2025 10:32
-
-
Save mattgperry/dbe63b9e1f51cd5e30d21dfd6fcd4a23 to your computer and use it in GitHub Desktop.
An example of modern Framer override APIs
This file contains hidden or 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 type { ComponentType } from "react" | |
import { createStore } from "https://framer.com/m/framer/store.js@^1.0.0" | |
const useStore = createStore({ | |
myVariant: "A" | |
}) | |
export function withSetVariant(Component): ComponentType { | |
return (props) => { | |
const [variant, setVariant] = useStore() | |
return <Component {...props} onClick={() => setVariant({ myVariant: "B" })} /> | |
} | |
} | |
export function withMyVariant(Component): ComponentType { | |
return (props) => { | |
const [variant] = useStore() | |
return <Component {...props} variant={variant} /> | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment