mirror of
https://github.com/revoltchat/revite.git
synced 2025-02-23 08:41:05 -05:00
16 lines
510 B
TypeScript
16 lines
510 B
TypeScript
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
import { connect, ConnectedComponent } from "react-redux";
|
|
|
|
import { h } from "preact";
|
|
import { memo } from "preact/compat";
|
|
|
|
import { State } from ".";
|
|
|
|
export function connectState<T>(
|
|
component: (props: any) => h.JSX.Element | null,
|
|
mapKeys: (state: State, props: T) => any,
|
|
memoize?: boolean,
|
|
): ConnectedComponent<(props: any) => h.JSX.Element | null, T> {
|
|
const c = connect(mapKeys)(component);
|
|
return memoize ? memo(c) : c;
|
|
}
|