Upgrade React-Redux (2nd attempt)

Summary:
- Update and include `react-redux` to Greenkeeper
- Remove legacy context which is used to access `store`
- Export `store` directly to use instead of legacy context

Note:
1st attempt: D18169584 -> got backouted in D18203354

Reviewed By: jknoxville

Differential Revision: D18297298

fbshipit-source-id: fd968f1b211eabb094113a0b35e84305f70117fc
This commit is contained in:
Chaiwat Ekkaewnumchai
2019-11-04 07:42:39 -08:00
committed by Facebook Github Bot
parent 61d4e0c6a5
commit c1130a167b
8 changed files with 264 additions and 253 deletions

View File

@@ -22,10 +22,10 @@ import {
colors,
} from 'flipper';
import {FlipperDevicePlugin, BaseAction} from './plugin';
import {connect} from 'react-redux';
import {connect, ReactReduxContext} from 'react-redux';
import {store} from './init';
import React, {Component, Fragment} from 'react';
import {clipboard} from 'electron';
import PropTypes from 'prop-types';
import {
PluginNotification,
clearAllNotifications,
@@ -49,51 +49,54 @@ export default class Notifications<
static icon = 'bell';
static keyboardActions: KeyboardActions = ['clear'];
static contextTypes = {
store: PropTypes.object.isRequired,
};
static supportsDevice() {
return false;
}
onKeyboardAction = (action: string) => {
if (action === 'clear') {
this.onClear();
this.onClear(store)();
}
};
onClear = () => {
(this.context.store as Store<StoreState>).dispatch(clearAllNotifications());
onClear = (store: Store<StoreState>) => () => {
store.dispatch(clearAllNotifications());
};
render() {
const {blacklistedPlugins, blacklistedCategories} = (this.context
.store as Store<StoreState>).getState().notifications;
return (
<ConnectedNotificationsTable
onClear={this.onClear}
selectedID={this.props.deepLinkPayload}
onSelectPlugin={this.props.selectPlugin}
logger={this.props.logger}
defaultFilters={[
...blacklistedPlugins.map(value => ({
value,
type: 'exclude',
key: 'plugin',
})),
...blacklistedCategories.map(value => ({
value,
type: 'exclude',
key: 'category',
})),
]}
actions={
<Fragment>
<Button onClick={this.onClear}>Clear</Button>
</Fragment>
}
/>
<ReactReduxContext.Consumer>
{({store}) => {
const {blacklistedPlugins, blacklistedCategories} = (store as Store<
StoreState
>).getState().notifications;
return (
<ConnectedNotificationsTable
onClear={this.onClear(store)}
selectedID={this.props.deepLinkPayload}
onSelectPlugin={this.props.selectPlugin}
logger={this.props.logger}
defaultFilters={[
...blacklistedPlugins.map(value => ({
value,
type: 'exclude',
key: 'plugin',
})),
...blacklistedCategories.map(value => ({
value,
type: 'exclude',
key: 'category',
})),
]}
actions={
<Fragment>
<Button onClick={this.onClear(store)}>Clear</Button>
</Fragment>
}
/>
);
}}
</ReactReduxContext.Consumer>
);
}
}