mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-29 17:42:38 +00:00
Combine setState calls in componentDidMount
This commit is contained in:
@@ -26,6 +26,7 @@ const NewPage = createClass({
|
|||||||
return {
|
return {
|
||||||
brew : {
|
brew : {
|
||||||
text : '',
|
text : '',
|
||||||
|
style : undefined,
|
||||||
shareId : null,
|
shareId : null,
|
||||||
editId : null,
|
editId : null,
|
||||||
createdAt : null,
|
createdAt : null,
|
||||||
@@ -46,6 +47,7 @@ const NewPage = createClass({
|
|||||||
return {
|
return {
|
||||||
brew : {
|
brew : {
|
||||||
text : this.props.brew.text || '',
|
text : this.props.brew.text || '',
|
||||||
|
style : this.props.brew.style || undefined,
|
||||||
gDrive : false,
|
gDrive : false,
|
||||||
title : this.props.brew.title || '',
|
title : this.props.brew.title || '',
|
||||||
description : this.props.brew.description || '',
|
description : this.props.brew.description || '',
|
||||||
@@ -67,16 +69,15 @@ const NewPage = createClass({
|
|||||||
const brewStorage = localStorage.getItem(BREWKEY);
|
const brewStorage = localStorage.getItem(BREWKEY);
|
||||||
const styleStorage = localStorage.getItem(STYLEKEY);
|
const styleStorage = localStorage.getItem(STYLEKEY);
|
||||||
|
|
||||||
|
const brew = this.state.brew;
|
||||||
|
|
||||||
if(!this.props.brew.text || !this.props.brew.style){
|
if(!this.props.brew.text || !this.props.brew.style){
|
||||||
this.setState({
|
brew.text = this.props.brew.text || (brewStorage ?? '');
|
||||||
brew : {
|
brew.style = this.props.brew.style || (styleStorage ?? undefined);
|
||||||
text : this.props.brew.text || (brewStorage ?? ''),
|
|
||||||
style : this.props.brew.style || (styleStorage ?? undefined)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState((prevState)=>({
|
this.setState((prevState)=>({
|
||||||
|
brew : brew,
|
||||||
htmlErrors : Markdown.validate(prevState.brew.text)
|
htmlErrors : Markdown.validate(prevState.brew.text)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user