mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-16 12:32:39 +00:00
Refactor ErrorNavItem to not need "this" parameter
Toward making edit/new/home pages functional, which do not have "this"
This commit is contained in:
@@ -438,6 +438,13 @@ const EditPage = createClass({
|
||||
return `https://www.reddit.com/r/UnearthedArcana/submit?title=${encodeURIComponent(title.toWellFormed())}&text=${encodeURIComponent(text)}`;
|
||||
},
|
||||
|
||||
clearError : function(){
|
||||
setState({
|
||||
error : null,
|
||||
isSaving : false
|
||||
})
|
||||
},
|
||||
|
||||
renderNavbar : function(){
|
||||
const shareLink = this.processShareId();
|
||||
|
||||
@@ -449,7 +456,7 @@ const EditPage = createClass({
|
||||
<Nav.section>
|
||||
{this.renderGoogleDriveIcon()}
|
||||
{this.state.error ?
|
||||
<ErrorNavItem error={this.state.error} parent={this}></ErrorNavItem> :
|
||||
<ErrorNavItem error={this.state.error} clearError={clearError}></ErrorNavItem> :
|
||||
<Nav.dropdown className='save-menu'>
|
||||
{this.renderSaveButton()}
|
||||
{this.renderAutoSaveButton()}
|
||||
|
||||
@@ -80,11 +80,19 @@ const HomePage = createClass({
|
||||
brew : { ...prevState.brew, text: text },
|
||||
}));
|
||||
},
|
||||
|
||||
clearError : function(){
|
||||
setState({
|
||||
error : null,
|
||||
isSaving : false
|
||||
})
|
||||
},
|
||||
|
||||
renderNavbar : function(){
|
||||
return <Navbar ver={this.props.ver}>
|
||||
<Nav.section>
|
||||
{this.state.error ?
|
||||
<ErrorNavItem error={this.state.error} parent={this}></ErrorNavItem> :
|
||||
<ErrorNavItem error={this.state.error} clearError={clearError}></ErrorNavItem> :
|
||||
null
|
||||
}
|
||||
<NewBrewItem />
|
||||
|
||||
@@ -211,6 +211,13 @@ const NewPage = createClass({
|
||||
}
|
||||
},
|
||||
|
||||
clearError : function(){
|
||||
setState({
|
||||
error : null,
|
||||
isSaving : false
|
||||
})
|
||||
},
|
||||
|
||||
renderNavbar : function(){
|
||||
return <Navbar>
|
||||
|
||||
@@ -220,7 +227,7 @@ const NewPage = createClass({
|
||||
|
||||
<Nav.section>
|
||||
{this.state.error ?
|
||||
<ErrorNavItem error={this.state.error} parent={this}></ErrorNavItem> :
|
||||
<ErrorNavItem error={this.state.error} clearError={clearError}></ErrorNavItem> :
|
||||
this.renderSaveButton()
|
||||
}
|
||||
<PrintNavItem />
|
||||
|
||||
@@ -39,10 +39,14 @@ const UserPage = (props)=>{
|
||||
}] : [])
|
||||
];
|
||||
|
||||
const clearError = ()=>{
|
||||
setError(null);
|
||||
};
|
||||
|
||||
const navItems = (
|
||||
<Navbar>
|
||||
<Nav.section>
|
||||
{error && (<ErrorNavItem error={error} parent={null}></ErrorNavItem>)}
|
||||
{error && (<ErrorNavItem error={error} clearError={clearError}></ErrorNavItem>)}
|
||||
<NewBrew />
|
||||
<HelpNavItem />
|
||||
<VaultNavitem />
|
||||
|
||||
Reference in New Issue
Block a user