swc-plugin-valtio

1.0.1 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i swc-plugin-valtio

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

2.94 MB

Total Files

3

Last publish

Collaborators

  • sosukesuzuki