primitives in Solid

signalimport { createSignal } from "solid-js"; const [getCount, setCount] = createSignal(0);声明了一个响应式变量console.log(getCount()); // 0 setCount(getCou...

signal

import { createSignal } from "solid-js";
const [getCount, setCount] = createSignal(0);

声明了一个响应式变量

console.log(getCount()); // 0
setCount(getCount() + 1);
console.log(getCount()); // 1

effect

import { createSignal, createEffect } from "solid-js";

const [getCount, setCount] = createSignal(0);
createEffect(() => console.log(getCount()));

会响应式地被触发