Remove support for legacy context (#1575)

* Remove support for legacy context

* Create chatty-walls-burn.md
This commit is contained in:
Nathan Bierema 2023-12-17 20:48:45 -05:00 committed by GitHub
parent 6f9ef2e941
commit decc035570
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 22 deletions

View File

@ -0,0 +1,5 @@
---
'@redux-devtools/core': major
---
Remove support for legacy context. Minimum supported react-redux version is 7.0.0 and minimum support React version is 16.8.4.

View File

@ -74,8 +74,8 @@
"typescript": "~5.3.3" "typescript": "~5.3.3"
}, },
"peerDependencies": { "peerDependencies": {
"react": "^0.14.9 || ^15.3.0 || ^16.0.0 || ^17.0.0 || ^18.0.0", "react": "^16.8.4 || ^17.0.0 || ^18.0.0",
"react-redux": "^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0", "react-redux": "^7.0.0 || ^8.0.0 || ^9.0.0",
"redux": "^3.5.2 || ^4.0.0 || ^5.0.0" "redux": "^3.5.2 || ^4.0.0 || ^5.0.0"
} }
} }

View File

@ -25,12 +25,7 @@ function logError(type: string) {
} }
} }
export interface Props< export interface Props<S, A extends Action<string>, MonitorState> {
S,
A extends Action<string>,
MonitorState,
MonitorAction extends Action<string>,
> {
store?: EnhancedStore<S, A, MonitorState>; store?: EnhancedStore<S, A, MonitorState>;
} }
@ -65,9 +60,7 @@ export default function createDevTools<
(state: LiftedState<S, A, MonitorState>) => state, (state: LiftedState<S, A, MonitorState>) => state,
)(Monitor as React.ComponentType<any>); )(Monitor as React.ComponentType<any>);
return class DevTools extends Component< return class DevTools extends Component<Props<S, A, MonitorState>> {
Props<S, A, MonitorState, MonitorAction>
> {
liftedStore?: LiftedStore<S, A, MonitorState>; liftedStore?: LiftedStore<S, A, MonitorState>;
static instrument = ( static instrument = (
@ -78,11 +71,8 @@ export default function createDevTools<
options, options,
); );
constructor( constructor(props: Props<S, A, MonitorState>) {
props: Props<S, A, MonitorState, MonitorAction>, super(props);
context?: { store?: EnhancedStore<S, A, MonitorState> },
) {
super(props, context);
if (ReactReduxContext) { if (ReactReduxContext) {
if (this.props.store && !this.props.store.liftedStore) { if (this.props.store && !this.props.store.liftedStore) {
@ -91,16 +81,12 @@ export default function createDevTools<
return; return;
} }
if (!props.store && !context?.store) { if (!props.store) {
logError('NoStore'); logError('NoStore');
return; return;
} }
if (context?.store) { this.liftedStore = props.store.liftedStore;
this.liftedStore = context.store.liftedStore;
} else {
this.liftedStore = props.store!.liftedStore;
}
if (!this.liftedStore) { if (!this.liftedStore) {
logError('NoLiftedStore'); logError('NoLiftedStore');