This package has been deprecated

Author message:

WARNING: This project has been renamed to babel-plugin-optimize-hook-destructuring. Install using babel-plugin-optimize-hook-destructuring instead.

babel-plugin-numeric-keys-array-destructure

1.1.1 • Public • Published

babel-plugin-numeric-keys-array-destructure

Babel plugin for transforming this const [value, setValue] = useState(null) to this const {0: value, 1: setValue} = useState(null);.

Note that this plugin only convert hooks (function name starting with use).

input:

function Foo() {
  // this gets converted to object destructuring:
  const [count, setCount] = useState(0);
 
  // but non-hook calls are not modified:
  const [a, b] = [0, 1];
  const [c, d] = otherThings();
  const f = 0;
}

output:

function Foo() {
  // this gets converted to object destructuring:
  const { 0: count, 1: setCount } = useState(0);
 
  // but non-hook calls are not modified:
  const [a, b] = [0, 1];
  const [c, d] = otherThings();
  const f = 0;
}

Readme

Keywords

none

Package Sidebar

Install

npm i babel-plugin-numeric-keys-array-destructure

Weekly Downloads

3

Version

1.1.1

License

GNUv3

Unpacked Size

148 kB

Total Files

6

Last publish

Collaborators

  • sanfilippopablo