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:
{ // this gets converted to object destructuring: const count setCount = ; // but non-hook calls are not modified: const a b = 0 1; const c d = ; const f = 0;}
output:
{ // this gets converted to object destructuring: const 0: count 1: setCount = ; // but non-hook calls are not modified: const a b = 0 1; const c d = ; const f = 0;}