1.0.6 • Published 2 years ago

react-effin v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Getting Started with use effin

Basics

This library is for slightly more functional versions of some items from react. basically they pass the arguments from the dependency list into the function calls. this lets you define functions for these outside of the context and avoid re-creating on each render.

useFnMemo

the signiture for this is the most similar to the React.useMemo

//was
const memo = useMemo(() => value * 5, [value])

//in this now...
//outside of the component even, or shared library
const memoFn = (value) => value * 5;

//in the component
const fnMemo = useFnMemo(memoFn, [value])

useFnEffect

This signiture is compatible overall with the normal useEffect

//was
useEffect(() => {
  fetch(url).then(setValue)
}, [url, setValue])

//in this now...
//outside of the component even, or shared library
const fetchFn = (url, setValue) => {
  fetch(url).then(setValue)
  return (url, setValue) => {
    //cleanup functionality works, but also gets values passed in.
  }
};

//in the component
useFnEffect(fetchFn, [value, setValue])

All variables are passed into the function in the order they are put into the array(s)

Things in process/ need some work

  • expansion needed? (useFnCallback seems like it would just be a useMemo)
1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago