1.0.1 • Published 4 years ago
swc-plugin-valtio v1.0.1
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_darwinFor Linux
cargo test_linuxRelease
npm run release -- --patchnpm run release -- --minornpm run release -- --major1.0.1
4 years ago