Skip to content

Commit

Permalink
AppDataFetcher [nfc]: Use useSelector instead of connect.
Browse files Browse the repository at this point in the history
An instance of zulip#4837.
  • Loading branch information
chrisbobbe committed Jul 1, 2021
1 parent 484b523 commit 9437d94
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/boot/AppDataFetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@
import React from 'react';

import type { Node as React$Node } from 'react';
import type { Dispatch } from '../types';
import { connect } from '../react-redux';
import { useSelector, useDispatch } from '../react-redux';
import { getSession } from '../directSelectors';
import { doInitialFetch } from '../actions';

type Props = $ReadOnly<{|
needsInitialFetch: boolean,
dispatch: Dispatch,
children: React$Node,
|}>;

function AppDataFetcher(props: Props) {
const { needsInitialFetch, dispatch } = props;
export default function AppDataFetcher(props: Props) {
const needsInitialFetch = useSelector(state => getSession(state).needsInitialFetch);
const dispatch = useDispatch();

React.useEffect(() => {
if (needsInitialFetch) {
Expand All @@ -25,7 +23,3 @@ function AppDataFetcher(props: Props) {

return props.children;
}

export default connect(state => ({
needsInitialFetch: getSession(state).needsInitialFetch,
}))(AppDataFetcher);

0 comments on commit 9437d94

Please sign in to comment.