Skip to content

Commit

Permalink
EditStreamScreen [nfc]: Convert to function component.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbobbe committed Aug 13, 2021
1 parent 124deaa commit 7767aed
Showing 1 changed file with 25 additions and 26 deletions.
51 changes: 25 additions & 26 deletions src/streams/EditStreamScreen.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* @flow strict-local */
import React, { PureComponent } from 'react';
import React, { useCallback } from 'react';

import type { RouteProp } from '../react-navigation';
import type { AppNavigationProp } from '../nav/AppNavigator';
Expand All @@ -23,31 +23,30 @@ type Props = $ReadOnly<{|
...SelectorProps,
|}>;

class EditStreamScreen extends PureComponent<Props> {
handleComplete = (name: string, description: string, isPrivate: boolean) => {
const { dispatch, stream } = this.props;

dispatch(updateExistingStream(stream.stream_id, stream, { name, description, isPrivate }));
NavigationService.dispatch(navigateBack());
};

render() {
const { stream } = this.props;

return (
<Screen title="Edit stream" padding>
<EditStreamCard
isNewStream={false}
initialValues={{
name: stream.name,
description: stream.description,
invite_only: stream.invite_only,
}}
onComplete={this.handleComplete}
/>
</Screen>
);
}
function EditStreamScreen(props: Props) {
const { dispatch, stream } = props;

const handleComplete = useCallback(
(name: string, description: string, isPrivate: boolean) => {
dispatch(updateExistingStream(stream.stream_id, stream, { name, description, isPrivate }));
NavigationService.dispatch(navigateBack());
},
[stream, dispatch],
);

return (
<Screen title="Edit stream" padding>
<EditStreamCard
isNewStream={false}
initialValues={{
name: stream.name,
description: stream.description,
invite_only: stream.invite_only,
}}
onComplete={handleComplete}
/>
</Screen>
);
}

export default connect<SelectorProps, _, _>((state, props) => ({
Expand Down

0 comments on commit 7767aed

Please sign in to comment.