Skip to content

Instantly share code, notes, and snippets.

View Stead08's full-sized avatar

Stead08 Stead08

View GitHub Profile
@Stead08
Stead08 / utils.tsx
Last active August 13, 2023 03:36
example of vitest in-source testing in solidjs project
import { createEffect, createRoot } from "solid-js";
import { createStore, type SetStoreFunction, type Store } from "solid-js/store";
export function createLocalStore<T extends object>(
name: string,
init: T
): [Store<T>, SetStoreFunction<T>] {
const localState = localStorage.getItem(name);
const [state, setState] = createStore<T>(localState ? JSON.parse(localState) : init);
createEffect(() => {