babel-plugin-reactive

0.0.1 • Public • Published

babel-plugin-reactive

This plugin allows you to declare a state just like declaring a normal variable, and then update the state like updating a normal variable.

This project is still an experiment, don't use it in a production.

In

import React from 'react';

export default () => {
  let count = 0;

  return (
    <button onClick={() => count += 1}>
      Clicked {count} {count === 1 ? 'time' : 'times'}
    </button>
  );
};

Out

import React, { useState } from 'react';

export default () => {
  let [count, setCount] = useState(0);

  return (
    <button onClick={() => setCount(_count => _count + 1)}>
      Clicked {count} {count === 1 ? 'time' : 'times'}
    </button>
  );
};

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i babel-plugin-reactive

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

132 kB

Total Files

13

Last publish

Collaborators

  • yesmeck