diff --git a/src/client/components/Settings/InputWithSave/index.jsx b/src/client/components/Settings/InputWithSave/index.jsx
index 1278846cc..74922a416 100644
--- a/src/client/components/Settings/InputWithSave/index.jsx
+++ b/src/client/components/Settings/InputWithSave/index.jsx
@@ -19,37 +19,48 @@ import { connect } from 'react-redux'
import helpers from 'lib/helpers'
import { updateSetting } from 'actions/settings'
+import { observer } from 'mobx-react'
+import { makeObservable, observable } from 'mobx'
+@observer
class InputWithSave extends React.Component {
+ @observable value = ''
+
constructor (props) {
super(props)
- this.state = {
- value: this.props.value
- }
+
+ makeObservable(this)
}
componentDidMount () {
+ this.value = this.props.initialValue ? this.props.initialValue : ''
helpers.UI.inputs()
}
- static getDerivedStateFromProps (nextProps, state) {
- if (!state.value) {
- return {
- value: nextProps.value
+ componentDidUpdate (prevProps, prevState, snapshot) {
+ if (typeof this.props.initialValue !== 'undefined') {
+ if (prevProps.initialValue !== this.props.initialValue) {
+ this.value = this.props.initialValue
}
}
-
- return null
}
+ // static getDerivedStateFromProps (nextProps, state) {
+ // if (!state.value) {
+ // return {
+ // value: nextProps.value
+ // }
+ // }
+ //
+ // return null
+ // }
+
onSaveClicked () {
- this.props.updateSetting({ name: this.props.settingName, value: this.state.value, stateName: this.props.stateName })
+ this.props.updateSetting({ name: this.props.settingName, value: this.value, stateName: this.props.stateName })
}
updateValue (evt) {
- this.setState({
- value: evt.target.value
- })
+ this.value = evt.target.value
}
render () {
@@ -63,7 +74,7 @@ class InputWithSave extends React.Component {
id={this.props.stateName}
className='md-input md-input-width-medium'
type='text'
- value={this.state.value}
+ value={this.value}
onChange={evt => this.updateValue(evt)}
/>
@@ -82,11 +93,9 @@ InputWithSave.propTypes = {
settingName: PropTypes.string.isRequired,
stateName: PropTypes.string.isRequired,
saveLabel: PropTypes.string,
+ initialValue: PropTypes.string,
value: PropTypes.string,
width: PropTypes.string
}
-export default connect(
- null,
- { updateSetting }
-)(InputWithSave)
+export default connect(null, { updateSetting })(InputWithSave)
diff --git a/src/client/containers/Settings/General/index.jsx b/src/client/containers/Settings/General/index.jsx
index 724eb8b0f..b74ea8433 100644
--- a/src/client/containers/Settings/General/index.jsx
+++ b/src/client/containers/Settings/General/index.jsx
@@ -70,11 +70,15 @@ class GeneralSettings extends React.Component {
const { active } = this.props
const SiteTitle = (
-
+
)
const SiteUrl = (
-
+
)
const Timezone = (
@@ -144,7 +148,7 @@ class GeneralSettings extends React.Component {
}
@@ -158,7 +162,7 @@ class GeneralSettings extends React.Component {
}
@@ -172,7 +176,7 @@ class GeneralSettings extends React.Component {
}
@@ -202,7 +206,4 @@ const mapStateToProps = state => ({
settings: state.settings.settings
})
-export default connect(
- mapStateToProps,
- { updateSetting }
-)(GeneralSettings)
+export default connect(mapStateToProps, { updateSetting })(GeneralSettings)