Fix compatibility of createDevTools with React 19 types (#1837)

* Fix compatibility of createDevTools with React 19 types

* Create fluffy-keys-doubt.md
This commit is contained in:
Nathan Bierema 2025-03-01 15:09:01 -05:00 committed by GitHub
parent ff60266836
commit 91f21b2ffc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 2 deletions

View File

@ -0,0 +1,5 @@
---
'@redux-devtools/core': patch
---
Fix compatibility of createDevTools with React 19 types

View File

@ -6,8 +6,9 @@ import {
LiftedState,
LiftedStore,
Options,
InstrumentExt,
} from '@redux-devtools/instrument';
import { Action } from 'redux';
import { Action, StoreEnhancer } from 'redux';
function logError(type: string) {
if (type === 'NoStore') {
@ -46,13 +47,32 @@ export type Monitor<
}
>;
export interface DevToolsInstance<S, A extends Action<string>, MonitorState>
extends Component<Props<S, A, MonitorState>> {
liftedStore?: LiftedStore<S, A, MonitorState>;
}
export interface DevToolsClass<
S,
A extends Action<string>,
MonitorState,
MonitorAction extends Action<string>,
> {
new (props: Props<S, A, MonitorState>): DevToolsInstance<S, A, MonitorState>;
instrument: (
options?: Options<S, A, MonitorState, MonitorAction>,
) => StoreEnhancer<InstrumentExt<any, any, MonitorState>>;
}
export default function createDevTools<
S,
A extends Action<string>,
MonitorProps extends LiftedState<S, A, MonitorState>,
MonitorState,
MonitorAction extends Action<string>,
>(children: Monitor<S, A, MonitorProps, MonitorState, MonitorAction>) {
>(
children: Monitor<S, A, MonitorProps, MonitorState, MonitorAction>,
): DevToolsClass<S, A, MonitorState, MonitorAction> {
const monitorElement = Children.only(children);
const monitorProps = monitorElement.props;
const Monitor = monitorElement.type;