Skip to content

Instantly share code, notes, and snippets.

@addisonschultz
addisonschultz / useScript.tsx
Last active October 28, 2023 10:02
A React hook that lets you add script tags to a component. Useful when needing to load scripts for components in Framer X.
import * as React from "react"
import { useState, useEffect } from "react"
// Hook
let cachedScripts = []
export function useScript(src) {
// Keeping track of script loaded and error state
const [state, setState] = useState({
loaded: false,
@koenbok
koenbok / store.ts
Last active November 10, 2023 00:17
import * as React from "react";
/**
A hook to simply use state between components
Warning: this only works with function components (like any hook)
Usage:
// You can put this in an central file and import it too
const useStore = createStore({ count: 0 })
import { Data, animate, Override, Animatable } from "framer";
const data = Data({ scaleValues: [] });
export const Scale: Override = props => {
data.scaleValues.push({ id: props.id, scaleValue: Animatable(1) });
return {
scale: getValueForId(props.id),
onTap() {
let valueToScale = getValueForId(props.id);