ref(live-streaming): remove picker state to remove componentWillReceiveProps

This commit is contained in:
Leonard Kim 2018-11-01 16:20:40 -07:00 committed by Leonard Kim
parent 3a32f7f3f0
commit d6216f21d5
3 changed files with 3 additions and 32 deletions

View File

@ -33,24 +33,13 @@ export type Props = {
value: string value: string
}; };
/**
* The state of the component.
*/
type State = {
/**
* The value entered in the field.
*/
value: string
}
/** /**
* An abstract React Component for entering a key for starting a YouTube live * An abstract React Component for entering a key for starting a YouTube live
* stream. * stream.
* *
* @extends Component * @extends Component
*/ */
export default class AbstractStreamKeyForm extends Component<Props, State> { export default class AbstractStreamKeyForm extends Component<Props> {
helpURL: string; helpURL: string;
/** /**
@ -61,10 +50,6 @@ export default class AbstractStreamKeyForm extends Component<Props, State> {
constructor(props: Props) { constructor(props: Props) {
super(props); super(props);
this.state = {
value: props.value
};
this.helpURL = (typeof interfaceConfig !== 'undefined' this.helpURL = (typeof interfaceConfig !== 'undefined'
&& interfaceConfig.LIVE_STREAMING_HELP_LINK) && interfaceConfig.LIVE_STREAMING_HELP_LINK)
|| LIVE_STREAMING_HELP_LINK; || LIVE_STREAMING_HELP_LINK;
@ -73,17 +58,6 @@ export default class AbstractStreamKeyForm extends Component<Props, State> {
this._onInputChange = this._onInputChange.bind(this); this._onInputChange = this._onInputChange.bind(this);
} }
/**
* Implements {@code Component}'s componentWillReceiveProps.
*
* @inheritdoc
*/
componentWillReceiveProps(newProps: Props) {
this.setState({
value: newProps.value
});
}
_onInputChange: Object => void _onInputChange: Object => void
/** /**
@ -99,9 +73,6 @@ export default class AbstractStreamKeyForm extends Component<Props, State> {
_onInputChange(change) { _onInputChange(change) {
const value = typeof change === 'object' ? change.target.value : change; const value = typeof change === 'object' ? change.target.value : change;
this.setState({
value
});
this.props.onChange(value); this.props.onChange(value);
} }
} }

View File

@ -50,7 +50,7 @@ class StreamKeyForm extends AbstractStreamKeyForm {
onChangeText = { this._onInputChange } onChangeText = { this._onInputChange }
placeholder = { t('liveStreaming.enterStreamKey') } placeholder = { t('liveStreaming.enterStreamKey') }
style = { styles.streamKeyInput } style = { styles.streamKeyInput }
value = { this.state.value } /> value = { this.props.value } />
<TouchableOpacity <TouchableOpacity
onPress = { this._onOpenHelp } onPress = { this._onOpenHelp }
style = { styles.streamKeyHelp } > style = { styles.streamKeyHelp } >

View File

@ -51,7 +51,7 @@ class StreamKeyForm extends AbstractStreamKeyForm {
placeholder = { t('liveStreaming.enterStreamKey') } placeholder = { t('liveStreaming.enterStreamKey') }
shouldFitContainer = { true } shouldFitContainer = { true }
type = 'text' type = 'text'
value = { this.state.value } /> value = { this.props.value } />
{ this.helpURL { this.helpURL
? <div className = 'form-footer'> ? <div className = 'form-footer'>
<a <a