From 49b1398d9f0729a2b4386136043c2fbc9a706f34 Mon Sep 17 00:00:00 2001 From: Ritesh Kumar Date: Thu, 31 Aug 2017 21:45:52 +0530 Subject: [PATCH] remove code from url --- components/ConversionPanel.js | 32 ++++++++++---------------------- components/Layout.js | 2 +- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/components/ConversionPanel.js b/components/ConversionPanel.js index c67122a..757d848 100644 --- a/components/ConversionPanel.js +++ b/components/ConversionPanel.js @@ -72,16 +72,19 @@ export default class ConversionPanel extends PureComponent { }; componentDidMount() { - const code = this.props.url.query.code || this.props.defaultText; - const splitValue = this.props.url.query.splitValue || this.props.splitValue; + const {defaultText, splitValue} = this.props + + const code = defaultText; + const sValue = splitValue; this.setState({ value: code, - splitValue, - resultValue: this.props.getTransformedValue(code, splitValue) + splitValue: sValue, + resultValue: this.props.getTransformedValue(code, sValue) }); } - onChange = (newValue: string, leftSplitValue: string) => { + onChange = (newValue, leftSplitValue) => { + debugger const nValue = newValue || this.state.value; const splitValue = leftSplitValue && typeof leftSplitValue === "string" @@ -96,8 +99,6 @@ export default class ConversionPanel extends PureComponent { info: "", infoType: "" }); - - this.setCodeInUrl(newValue, leftSplitValue); } catch (e) { this.setState({ info: e.message, @@ -111,17 +112,7 @@ export default class ConversionPanel extends PureComponent { }); }; - setCodeInUrl = (code, leftSplitValue) => { - Router.replace({ - pathname: this.props.url.pathname, - query: { - code, - splitValue: leftSplitValue - } - }); - }; - - toggleCheckbox = (e: MouseEvent) => { + toggleCheckbox = (e) => { const checked = e.currentTarget.checked; if (this.props.onCheckboxChange) { this.props.onCheckboxChange(checked, () => { @@ -132,13 +123,10 @@ export default class ConversionPanel extends PureComponent { } }; - setResult = (result: string) => { + setResult = (result) => { this.setState( { value: result - }, - () => { - this.setCodeInUrl(result); } ); }; diff --git a/components/Layout.js b/components/Layout.js index 4a6659f..9c08fc1 100644 --- a/components/Layout.js +++ b/components/Layout.js @@ -430,7 +430,7 @@ export default class Layout extends PureComponent { } > {route.content.map(a => ( - + {a.label} ))}