Skip to content

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

License

Notifications You must be signed in to change notification settings

tcK1/useAssignmentState

Repository files navigation

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages