1.0.1 • Published 2 years ago

swc-plugin-valtio v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

swc-plugin-valtio

Valtio useProxy transformer for SWC.

Example

import { useProxy } from 'valtio/macro'

const Component = () => {
  useProxy(state);
  return (
    <div>
      {state.count}
      <button onClick={() => ++state.count}>
        +1
      </button>
    </div>
  );
}

// The code above becomes the code below.

import { useSnapshot } from 'valtio';

const Component = () => {
  const valtio_macro_snap_state = useSnapshot(state);
  return (
    <div>
      {valtio_macro_snap_state.count}
      <button onClick={() => ++state.count}>
        +1
      </button>
    </div>
  );
}

Tests

For MacOS

cargo test_darwin

For Linux

cargo test_linux

Release

npm run release -- --patch
npm run release -- --minor
npm run release -- --major