Skip to content

Commit 48066e4

Browse files
lbogdanCompuIves
authored andcommitted
Fix onClick={cond && func} (codesandbox#211)
1 parent efca732 commit 48066e4

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

src/app/components/sandbox/CodeEditor/Monaco.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ export default class CodeEditor extends React.Component<Props, State> {
872872
return (
873873
<Container>
874874
<Header
875-
saveComponent={canSave && !onlyViewMode && this.handleSaveCode}
875+
saveComponent={canSave && !onlyViewMode ? this.handleSaveCode : null}
876876
prettify={!onlyViewMode && this.prettify}
877877
path={modulePath}
878878
/>

src/app/components/sandbox/Preview/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,9 @@ export default class Preview extends React.PureComponent<Props, State> {
347347
url={decodeURIComponent(url)}
348348
onChange={this.updateUrl}
349349
onConfirm={this.sendUrl}
350-
onBack={historyPosition > 1 && this.handleBack}
350+
onBack={historyPosition > 1 ? this.handleBack : null}
351351
onForward={
352-
historyPosition < history.length - 1 && this.handleForward
352+
historyPosition < history.length - 1 ? this.handleForward : null
353353
}
354354
onRefresh={this.handleRefresh}
355355
isProjectView={isInProjectView}

src/app/containers/LikeHeart/LikeHeart.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ export default class LikeHeart extends React.PureComponent {
6161
{isLiked ? (
6262
<FullHeartIcon
6363
style={!colorless && { color: '#E01F4E' }}
64-
onClick={loggedIn && this.unlikeSandbox}
64+
onClick={loggedIn ? this.unlikeSandbox : null}
6565
/>
6666
) : (
67-
<HeartIcon onClick={loggedIn && this.likeSandbox} />
67+
<HeartIcon onClick={loggedIn ? this.likeSandbox : null} />
6868
)}
6969
</MaybeTooltip>
7070
</Container>

src/app/pages/Sandbox/Editor/Content/Header/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,20 +221,20 @@ export default class Header extends React.PureComponent<Props> {
221221
))}
222222
<Action onClick={this.forkSandbox} title="Fork" Icon={Fork} />
223223
<Action
224-
onClick={canSave && this.massUpdateModules}
224+
onClick={canSave ? this.massUpdateModules : null}
225225
placeholder={canSave ? false : 'All modules are saved'}
226226
title="Save"
227227
Icon={Save}
228228
/>
229229
<Action title="Download" Icon={Download} onClick={this.zipSandbox} />
230230
{user.jwt &&
231-
sandbox.owned && (
232-
<Action
233-
title="Deploy"
234-
Icon={NowIcon}
235-
onClick={this.deploySandbox}
236-
/>
237-
)}
231+
sandbox.owned && (
232+
<Action
233+
title="Deploy"
234+
Icon={NowIcon}
235+
onClick={this.deploySandbox}
236+
/>
237+
)}
238238
<ShareView sandbox={sandbox} />
239239
</Left>
240240

0 commit comments

Comments
 (0)