Skip to content

Commit f4a9bfa

Browse files
committed
in titledhoc, consolidate function calls
1 parent b6ff1f4 commit f4a9bfa

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/lib/titled-hoc.jsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ const messages = defineMessages({
2121
const TitledHOC = function (WrappedComponent) {
2222
class TitledComponent extends React.Component {
2323
componentDidMount () {
24-
this.props.updateReduxProjectTitle(this.titleWithDefault(this.props.projectTitle));
24+
this.updateReduxProjectTitleWithDefault(this.props.projectTitle);
2525
}
2626
componentDidUpdate (prevProps) {
2727
if (this.props.projectTitle !== prevProps.projectTitle) {
28-
this.props.updateReduxProjectTitle(this.titleWithDefault(this.props.projectTitle));
28+
this.updateReduxProjectTitleWithDefault(this.props.projectTitle);
2929
}
3030
// if the projectTitle hasn't changed, but the reduxProjectTitle
3131
// HAS changed, we need to report that change to the projectTitle's owner
@@ -34,11 +34,12 @@ const TitledHOC = function (WrappedComponent) {
3434
this.props.onUpdateProjectTitle(this.props.reduxProjectTitle);
3535
}
3636
}
37-
titleWithDefault (title) {
38-
if (title === null || typeof title === 'undefined') {
39-
return this.props.intl.formatMessage(messages.defaultProjectTitle);
37+
updateReduxProjectTitleWithDefault (requestedTitle) {
38+
let newTitle = requestedTitle;
39+
if (newTitle === null || typeof newTitle === 'undefined') {
40+
newTitle = this.props.intl.formatMessage(messages.defaultProjectTitle);
4041
}
41-
return title;
42+
this.props.updateReduxProjectTitle(newTitle);
4243
}
4344
render () {
4445
const {

0 commit comments

Comments
 (0)