revite/src/redux/connector.tsx

21 lines
652 B
TypeScript
Raw Normal View History

2021-06-18 14:25:33 -04:00
/* eslint-disable @typescript-eslint/no-explicit-any */
import { State } from ".";
import { h } from "preact";
2021-06-18 14:25:33 -04:00
// import { memo } from "preact/compat";
import { connect, ConnectedComponent } from "react-redux";
export function connectState<T>(
component: (props: any) => h.JSX.Element | null,
mapKeys: (state: State, props: T) => any,
useDispatcher?: boolean
): ConnectedComponent<(props: any) => h.JSX.Element | null, T> {
return (
useDispatcher
2021-06-18 14:25:33 -04:00
? connect(mapKeys, (dispatcher) => {
return { dispatcher };
})
: connect(mapKeys)
2021-06-18 14:25:33 -04:00
)(component); //(memo(component));
}