0.3.0 • Published 6 years ago

react-angler v0.3.0

Weekly downloads
5
License
MIT
Repository
github
Last release
6 years ago

React-angler

npm version Build Status Bundle size codecov

Personally i love functionally approaching problems, that's why i challenged myself to make this little library. This was a good introduction to TypeScript aswell.

Enjoy!

Installation

yarn

  yarn add react-angler

npm

  npm i --save react-angler

UMD

dev:

<script src="https://unpkg.com/react-angler@latest/dist/react-angler.umd.js"></script>

prod:

<script src="https://unpkg.com/react-angler@latest/dist/prod/react-angler.umd.js"></script>

The hooks

component-hooks

nameinputoutput
useActive/ref, isActive
useComponentSize/ref, { width, height }
useFocus/ref, isFocussed
useHover/ref, isHovered

Just put the received ref on a DOMNode and watch the magic happen.

dom-hooks

nameinputoutput
useTitletitle/
useWindowSize{ width, height}

useTitle sets the pageTitle in head.

lifecycle-hooks

nameinputoutput
useDidMountfunction/
useDidUnmountfunction/
useDidUpdatefunction, arrayOfWatchableProps/

useDidUpdate is good combined with usePreviousValue to see prevProps and current props.

state-hooks

nameinputoutput
useArrayinitialValue
useCounterinitialValue{ decrease, increase, setValue, value }
useInputinitialValue{ clear, setValue, onChange, value }
useMapinitialValue{ get, getMultiple, remove, set, value }
useStateinitialValue{ setState, state }
useToggleinitialValue{ toggle, setTrue, setFalse, value }

inputs here are optional and will default to a reasonable default.

Array-payload

  • add: takes an element and adds it.
  • clear: gives you a new empty array
  • makeUnique: removes duplicate values (by refference)
  • remove: given a function that returns a new array
  • removeByElement: given an element removes it
  • removeByIndex: given an index removes it
  • setValue: manually set the array
  • value: the array

util-hooks

nameinputoutput
usePreviousValueany varprevious value of that var
useLocalStoragekey, initial{ setValue, value }
useNetworkStatus/currentNetworkStatus
0.3.0

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago