1.0.7 • Published 3 months ago

@jswork/next-react-valtio v1.0.7

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

next-react-valtio

Valtio for react.

version license size download

installation

yarn add valtio derive-valtio
yarn add @jswork/next-react-valtio

usage

import '@jswork/next-react-valtio';
const InteractiveList = () => {
  const { state, store, ...derived } = nx.$valtio<number[]>([1, 2, 3, 4]);
  return (
    <div className="bg-slate-100 p-2">
      <h1>Vite + React</h1>
      <nav className="mt-4 flex gap-1 border border-solid p-1">
        <button onClick={() => store.push(state.length + 1)}>添加</button>
        <button
          onClick={() => {
            store.splice(0, state.length, ...['a', 'b', 'c', 'd', 'e']);
          }}>
          Reset
        </button>
      </nav>
      {state.map((item, index) => (
        <div className="m-2 block border" key={index}>
          <span className="bold mr-1">{item}</span>
          <button onClick={() => store.splice(index, 1)}>删除</button>
        </div>
      ))}
      {state.length === 0 && <div className="m-2 block border">暂无数据</div>}
    </div>
  );
};

export default InteractiveList;

license

Code released under the MIT license.

1.0.2

3 months ago

1.0.7

3 months ago

1.0.6

3 months ago

1.0.5

3 months ago

1.0.3

3 months ago

1.0.1

4 months ago