From f3f81042b9dbd961d70b9842daadbc7e015638a5 Mon Sep 17 00:00:00 2001 From: Chris Bobbe Date: Tue, 27 Jul 2021 16:00:40 -0400 Subject: [PATCH] EditStreamScreen [nfc]: Use `useSelector` instead of `connect`. An instance of #4837. --- src/streams/EditStreamScreen.js | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/streams/EditStreamScreen.js b/src/streams/EditStreamScreen.js index 04b56cafb33..0592e380ce1 100644 --- a/src/streams/EditStreamScreen.js +++ b/src/streams/EditStreamScreen.js @@ -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) => { @@ -48,7 +41,3 @@ function EditStreamScreen(props: Props) { ); } - -export default connect((state, props) => ({ - stream: getStreamForId(state, props.route.params.streamId), -}))(EditStreamScreen);