Skip to content

Commit

Permalink
feat: use optional chain expression in components (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
mathdevelop authored Oct 30, 2023
1 parent dc14904 commit 22e39d9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/components/ErrorBoundary.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class ErrorBoundary extends Component {
? "Something went wrong in component '{{type}}'. {{error}}"
: "Something went wrong with the component type.";
const text = replaceData(i18n[errorMsg], {
type: type && type.toString(),
error: this.state.error && this.state.error.toString()
type: type?.toString(),
error: this.state.error?.toString()
});
return (
<CommonBlock {...this.props} actions={this.actions}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/MegadraftEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ export default class MegadraftEditor extends Component {
};

const input = control.querySelector("[type=text]");
input && input.focus();
input?.focus();

control.scrollIntoView({ block: "center" });
window.scroll(0, window.scrollY - control.clientHeight / 2);
Expand Down
4 changes: 2 additions & 2 deletions src/components/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default class Toolbar extends Component {
case "custom": {
key = "custom-" + position;
toggle = () => item.action(this.props.editorState, this.props.onChange);
active = item.active && item.active(this.props.editorState);
active = item.active?.(this.props.editorState);
break;
}
case "inline": {
Expand Down Expand Up @@ -239,7 +239,7 @@ export default class Toolbar extends Component {
error: null
},
() => {
this.props.draft && this.props.draft.focus();
this.props.draft?.focus();
}
);
}
Expand Down

0 comments on commit 22e39d9

Please sign in to comment.