Skip to content

Instantly share code, notes, and snippets.

@ruucm-working
Last active May 30, 2025 05:23
Show Gist options
  • Save ruucm-working/200e5e65c5cb77eaf790799244bc1392 to your computer and use it in GitHub Desktop.
Save ruucm-working/200e5e65c5cb77eaf790799244bc1392 to your computer and use it in GitHub Desktop.
import { forwardRef, type ComponentType } from "react"
import { createStore } from "https://framer.com/m/framer/store.js@^1.0.0"
// [1] Store (Save states globally)
// This is the same as the variables in the Framer Canvas
const useStore = createStore({
// key: value
// value is string, number, boolean, object, array, etc..
// string should have quotes ("")
// boolean could have true, false
background: "red",
})
export function myOverride1(Component): ComponentType {
return forwardRef((props, ref) => {
const [store, setStore] = useStore()
return (
<Component
ref={ref}
{...props}
// [2] Properties (style, text, variant, etc..)
// This is the same as the Properties panel in the Framer Canvas
// propertyName={value}
style={{
background: store.background,
}}
// [3] Event Properties (onClick, onMouseEnter, onMouseLeave, etc..)
// This is the same as the Interactions panel in the Framer Canvas
// eventPropertyName={function}
// if () {}
// else if () {}
// else {}
onClick={() => {
setStore({ background: "blue" })
}}
/>
)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment