aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/components/NewPaste.js
diff options
context:
space:
mode:
authorjackyzha0 <[email protected]>2020-05-12 23:08:20 -0700
committerjackyzha0 <[email protected]>2020-05-12 23:08:20 -0700
commit94a9b304546dd1213ef2f15e57f5966ab88b80b7 (patch)
tree6d583219cb9bcf04ca521d35a9edfb8c6838fe1b /frontend/src/components/NewPaste.js
parentMerge branch 'master' of https://github.com/jackyzha0/ctrl-v into pass-rendering (diff)
downloadctrl-v-94a9b304546dd1213ef2f15e57f5966ab88b80b7.tar.xz
ctrl-v-94a9b304546dd1213ef2f15e57f5966ab88b80b7.zip
abstract err show logic
Diffstat (limited to 'frontend/src/components/NewPaste.js')
-rw-r--r--frontend/src/components/NewPaste.js14
1 files changed, 4 insertions, 10 deletions
diff --git a/frontend/src/components/NewPaste.js b/frontend/src/components/NewPaste.js
index 1409c22..f48f48b 100644
--- a/frontend/src/components/NewPaste.js
+++ b/frontend/src/components/NewPaste.js
@@ -19,13 +19,7 @@ class NewPaste extends React.Component {
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
- }
-
- newErr(msg, duration = 5000) {
- this.setState({ error: msg })
- setTimeout(() => {
- this.setState({ error: '' })
- }, duration);
+ this.ErrorLabel = React.createRef();
}
renderRedirect = () => {
@@ -64,10 +58,10 @@ class NewPaste extends React.Component {
// some weird err
if (resp !== undefined) {
const errTxt = `${resp.statusText}: ${resp.data}`
- this.newErr(errTxt)
+ this.ErrorLabel.current.showMessage(errTxt)
} else {
// some weird err (e.g. network)
- this.newErr(error)
+ this.ErrorLabel.current.showMessage(error)
}
});
}
@@ -87,7 +81,7 @@ class NewPaste extends React.Component {
maxLength="100000"
id="pasteInput" />
<input className="lt-button lt-shadow lt-hover" type="submit" value="new paste" />
- <Error msg={this.state.error} />
+ <Error ref={this.ErrorLabel} />
<OptionsContainer
pass={this.state.pass}
expiry={this.state.expiry}