summaryrefslogtreecommitdiffstats
path: root/ui/src/components/listing-type-select.tsx
diff options
context:
space:
mode:
authorderek <wwsage@gmail.com>2020-07-13 00:19:34 -0400
committerderek <wwsage@gmail.com>2020-07-13 20:14:01 -0400
commit47548905ce1b20035ffa467391f06280b6fbfcb4 (patch)
treedf83020eb7ff82bd699a354a6e9b65bd651b0225 /ui/src/components/listing-type-select.tsx
parent195bf022bb38499754263f71d52b0596ebd0e333 (diff)
ui.components: fix selector components to work with browser buttons
Use getDerivedState to set state and only send back props
Diffstat (limited to 'ui/src/components/listing-type-select.tsx')
-rw-r--r--ui/src/components/listing-type-select.tsx15
1 files changed, 10 insertions, 5 deletions
diff --git a/ui/src/components/listing-type-select.tsx b/ui/src/components/listing-type-select.tsx
index d583b93c..6d13f19a 100644
--- a/ui/src/components/listing-type-select.tsx
+++ b/ui/src/components/listing-type-select.tsx
@@ -26,6 +26,12 @@ export class ListingTypeSelect extends Component<
this.state = this.emptyState;
}
+ static getDerivedStateFromProps(props) {
+ return {
+ type_: props.type_,
+ };
+ }
+
render() {
return (
<div class="btn-group btn-group-toggle">
@@ -45,8 +51,9 @@ export class ListingTypeSelect extends Component<
{i18n.t('subscribed')}
</label>
<label
- className={`pointer btn btn-sm btn-secondary ${this.state.type_ ==
- ListingType.All && 'active'}`}
+ className={`pointer btn btn-sm btn-secondary ${
+ this.state.type_ == ListingType.All && 'active'
+ }`}
>
<input
type="radio"
@@ -61,8 +68,6 @@ export class ListingTypeSelect extends Component<
}
handleTypeChange(i: ListingTypeSelect, event: any) {
- i.state.type_ = Number(event.target.value);
- i.setState(i.state);
- i.props.onChange(i.state.type_);
+ i.props.onChange(Number(event.target.value));
}
}