Skip to content

Commit

Permalink
EditStreamScreen [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 Aug 27, 2021
1 parent a094d3d commit f3f8104
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions src/streams/EditStreamScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,20 @@ import React, { useCallback } from 'react';
import type { RouteProp } from '../react-navigation';
import type { AppNavigationProp } from '../nav/AppNavigator';
import * as NavigationService from '../nav/NavigationService';
import type { Dispatch, Stream } from '../types';
import { connect } from '../react-redux';
import { useSelector, useDispatch } from '../react-redux';
import { updateExistingStream, navigateBack } from '../actions';
import { getStreamForId } from '../selectors';
import { Screen } from '../common';
import EditStreamCard from './EditStreamCard';

type SelectorProps = $ReadOnly<{|
stream: Stream,
|}>;

type Props = $ReadOnly<{|
navigation: AppNavigationProp<'edit-stream'>,
route: RouteProp<'edit-stream', {| streamId: number |}>,

dispatch: Dispatch,
...SelectorProps,
|}>;

function EditStreamScreen(props: Props) {
const { dispatch, stream } = props;
export default function EditStreamScreen(props: Props) {
const dispatch = useDispatch();
const stream = useSelector(state => getStreamForId(state, props.route.params.streamId));

const handleComplete = useCallback(
(name: string, description: string, isPrivate: boolean) => {
Expand All @@ -48,7 +41,3 @@ function EditStreamScreen(props: Props) {
</Screen>
);
}

export default connect<SelectorProps, _, _>((state, props) => ({
stream: getStreamForId(state, props.route.params.streamId),
}))(EditStreamScreen);

0 comments on commit f3f8104

Please sign in to comment.