0.0.3 • Published 4 years ago

@zecos/propz v0.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

propz

propz is a fairly simple library that simply returns commonly used props given a fieldName, state, and actions.

Mostly meant for combined use with @zecos/ui.

Example Usage

import { propz } from 'propz'

const Form = () => {
  const [state, actions] = useFieldz({username: {init: ""}})
  const props = propz({fieldName: "username", state, actions})
  return (
    <form>
    <input {...props} />
    </form>
  )
}

This will use the fieldName property to generate commonly used props like

  • id (kebab-case)
  • name (kebab-case)
  • label (Title Case)
  • aria-label (Title Case)

It uses the state and actions properties to generate

  • value
  • onChange
  • onBlur