diff options
Diffstat (limited to 'src/components/ui')
-rw-r--r-- | src/components/ui/Link.js | 2 | ||||
-rw-r--r-- | src/components/ui/button/index.tsx | 22 | ||||
-rw-r--r-- | src/components/ui/infobox/index.tsx | 4 | ||||
-rw-r--r-- | src/components/ui/select/index.tsx | 15 | ||||
-rw-r--r-- | src/components/ui/textarea/index.tsx | 2 | ||||
-rw-r--r-- | src/components/ui/toggle/index.tsx | 4 |
6 files changed, 24 insertions, 25 deletions
diff --git a/src/components/ui/Link.js b/src/components/ui/Link.js index 5ab19bf74..714fc5a68 100644 --- a/src/components/ui/Link.js +++ b/src/components/ui/Link.js | |||
@@ -1,7 +1,7 @@ | |||
1 | import { Component } from 'react'; | 1 | import { Component } from 'react'; |
2 | import PropTypes from 'prop-types'; | 2 | import PropTypes from 'prop-types'; |
3 | import { inject, observer } from 'mobx-react'; | 3 | import { inject, observer } from 'mobx-react'; |
4 | import { RouterStore } from 'mobx-react-router'; | 4 | import { RouterStore } from '@superwf/mobx-react-router'; |
5 | import classnames from 'classnames'; | 5 | import classnames from 'classnames'; |
6 | 6 | ||
7 | import { oneOrManyChildElements } from '../../prop-types'; | 7 | import { oneOrManyChildElements } from '../../prop-types'; |
diff --git a/src/components/ui/button/index.tsx b/src/components/ui/button/index.tsx index 26fd6bcfe..a8bbfe730 100644 --- a/src/components/ui/button/index.tsx +++ b/src/components/ui/button/index.tsx | |||
@@ -169,20 +169,18 @@ class ButtonComponent extends Component<IProps> { | |||
169 | busy: false, | 169 | busy: false, |
170 | }; | 170 | }; |
171 | 171 | ||
172 | componentWillMount() { | 172 | constructor(props: IProps) { |
173 | this.setState({ busy: this.props.busy }); | 173 | super(props); |
174 | |||
175 | this.state = { | ||
176 | busy: props.busy || false, | ||
177 | }; | ||
174 | } | 178 | } |
175 | 179 | ||
176 | componentWillReceiveProps(nextProps: IProps) { | 180 | static getDerivedStateFromProps(nextProps: IProps) { |
177 | if (nextProps.busy !== this.props.busy) { | 181 | return { |
178 | if (this.props.busy) { | 182 | busy: nextProps.busy, |
179 | setTimeout(() => { | 183 | }; |
180 | this.setState({ busy: nextProps.busy }); | ||
181 | }, 300); | ||
182 | } else { | ||
183 | this.setState({ busy: nextProps.busy }); | ||
184 | } | ||
185 | } | ||
186 | } | 184 | } |
187 | 185 | ||
188 | render() { | 186 | render() { |
diff --git a/src/components/ui/infobox/index.tsx b/src/components/ui/infobox/index.tsx index 976ed5bc4..d1d7ef6cd 100644 --- a/src/components/ui/infobox/index.tsx +++ b/src/components/ui/infobox/index.tsx | |||
@@ -199,6 +199,4 @@ class InfoboxComponent extends Component<IProps, IState> { | |||
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | export default injectStyle(styles, { injectTheme: true })( | 202 | export default injectStyle(styles, { injectTheme: true })(InfoboxComponent); |
203 | InfoboxComponent, | ||
204 | ); | ||
diff --git a/src/components/ui/select/index.tsx b/src/components/ui/select/index.tsx index c3b5314e3..1ce6c674b 100644 --- a/src/components/ui/select/index.tsx +++ b/src/components/ui/select/index.tsx | |||
@@ -177,12 +177,16 @@ class SelectComponent extends Component<IProps> { | |||
177 | 177 | ||
178 | private keyListener: any; | 178 | private keyListener: any; |
179 | 179 | ||
180 | componentWillReceiveProps(nextProps: IProps) { | 180 | static getDerivedStateFromProps(nextProps: IProps, prevState: IProps) { |
181 | if (nextProps.value && nextProps.value !== this.props.value) { | 181 | if (nextProps.value && nextProps.value !== prevState.value) { |
182 | this.setState({ | 182 | return { |
183 | value: nextProps.value, | 183 | value: nextProps.value, |
184 | }); | 184 | }; |
185 | } | 185 | } |
186 | |||
187 | return { | ||
188 | value: prevState.value, | ||
189 | }; | ||
186 | } | 190 | } |
187 | 191 | ||
188 | componentDidUpdate() { | 192 | componentDidUpdate() { |
@@ -199,6 +203,7 @@ class SelectComponent extends Component<IProps> { | |||
199 | 203 | ||
200 | if (data) { | 204 | if (data) { |
201 | Object.keys(data).map( | 205 | Object.keys(data).map( |
206 | // eslint-disable-next-line no-return-assign | ||
202 | key => (this.inputRef.current!.dataset[key] = data[key]), | 207 | key => (this.inputRef.current!.dataset[key] = data[key]), |
203 | ); | 208 | ); |
204 | } | 209 | } |
@@ -458,6 +463,6 @@ class SelectComponent extends Component<IProps> { | |||
458 | } | 463 | } |
459 | } | 464 | } |
460 | 465 | ||
461 | export const Select = injectStyle(styles, { injectTheme: true })( | 466 | export default injectStyle(styles, { injectTheme: true })( |
462 | SelectComponent, | 467 | SelectComponent, |
463 | ); | 468 | ); |
diff --git a/src/components/ui/textarea/index.tsx b/src/components/ui/textarea/index.tsx index e005767f8..6796ab83d 100644 --- a/src/components/ui/textarea/index.tsx +++ b/src/components/ui/textarea/index.tsx | |||
@@ -121,6 +121,6 @@ class TextareaComponent extends Component<IProps> { | |||
121 | } | 121 | } |
122 | } | 122 | } |
123 | 123 | ||
124 | export const Textarea = injectSheet(styles, { injectTheme: true })( | 124 | export default injectSheet(styles, { injectTheme: true })( |
125 | TextareaComponent, | 125 | TextareaComponent, |
126 | ); | 126 | ); |
diff --git a/src/components/ui/toggle/index.tsx b/src/components/ui/toggle/index.tsx index 0629d1a2c..d478cbba5 100644 --- a/src/components/ui/toggle/index.tsx +++ b/src/components/ui/toggle/index.tsx | |||
@@ -122,6 +122,4 @@ class ToggleComponent extends Component<IProps> { | |||
122 | } | 122 | } |
123 | } | 123 | } |
124 | 124 | ||
125 | export default injectStyle(styles, { injectTheme: true })( | 125 | export default injectStyle(styles, { injectTheme: true })(ToggleComponent); |
126 | ToggleComponent, | ||
127 | ); | ||