use-assignment-state

1.0.1 • Public • Published

useAssignmentState · NPM

React hook that give you the ability to have an state object that can perform changes with an assignment call.

I made this hook inspired in the new svelte 3.0 syntax, wich you can look here.

This was created for fun and, to be honest, I don`t really know if you should be using it, but that's your choice.

Install

npm install --save use-assignment-state

or

yarn add use-assignment-state

Usage

import React from 'react'
import useAssignmentState from 'use-assignment-state'

const Example = () => {
  const state = useAssignmentState({
    key: 'val',
  });

  return (
    <input
      value={state.key}
      onChange={(e) => { state.key = e.target.value; }}
    />
  );
};

More examples

You can check more examples here.

License

MIT © tcK1

Dependencies (0)

    Dev Dependencies (13)

    Package Sidebar

    Install

    npm i use-assignment-state

    Weekly Downloads

    0

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    447 kB

    Total Files

    14

    Last publish

    Collaborators

    • tck