react-stateful-function
Advanced tools
Comparing version 0.0.1 to 0.0.2
16
index.ts
@@ -1,14 +0,2 @@ | ||
import { useEffect, useReducer } from 'react'; | ||
const mini_reducer = (state = {}, action) => ({ ...state, [action.type]: action.payload }); | ||
const constructState = (initialState: object = {}) => { | ||
const [state, dispatch] = useReducer(mini_reducer, initialState); | ||
const setState = (fState = {}) => { for (const type in fState) {dispatch({ type, payload: fState[type] });} }; | ||
const resetState = () => setState(initialState); | ||
return { state, setState, resetState }; | ||
}; | ||
const funcDidMount = (doAfterMount: Function) => useEffect(() => { doAfterMount(); }, [doAfterMount]); | ||
const funcWillUnmount = (doBeforeUnmount: Function) => useEffect( () => { return () => doBeforeUnmount(); }, [doBeforeUnmount]); | ||
const funcDidUpdate = (values: Array<string>, doOnChange: Function) => useEffect(() => { doOnChange(); }, [values]); | ||
export { constructState, funcDidMount, funcWillUnmount, funcDidUpdate }; | ||
export * from "./example"; | ||
export * from "./src"; |
{ | ||
"name": "react-stateful-function", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "React Statful Function", | ||
@@ -5,0 +5,0 @@ "main": "index.ts", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4323
11
63