Skip to content

Commit 6fc0d3f

Browse files
Fix publish button
1 parent 7a91e4d commit 6fc0d3f

File tree

1 file changed

+23
-29
lines changed

1 file changed

+23
-29
lines changed

app/src/components/Sidebar/Publish/Publish.tsx

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function Publish(props: Props) {
102102
)
103103
}
104104

105-
function EditorMode(props: {
105+
const EditorMode = memo(function EditorMode(props: {
106106
payload?: string
107107
editorMode: string
108108
focusEditor: () => void
@@ -127,21 +127,18 @@ function EditorMode(props: {
127127
}
128128
}, [props.payload])
129129

130-
return useMemo(
131-
() => (
132-
<div style={{ marginTop: '16px' }}>
133-
<div style={{ width: '100%', lineHeight: '64px', textAlign: 'center' }}>
134-
<EditorModeSelect value={props.editorMode} onChange={updateMode} focusEditor={props.focusEditor} />
135-
<FormatJsonButton editorMode={props.editorMode} focusEditor={props.focusEditor} formatJson={formatJson} />
136-
<div style={{ float: 'right' }}>
137-
<PublishButton publish={props.publish} focusEditor={props.focusEditor} />
138-
</div>
130+
return (
131+
<div style={{ marginTop: '16px' }}>
132+
<div style={{ width: '100%', lineHeight: '64px', textAlign: 'center' }}>
133+
<EditorModeSelect value={props.editorMode} onChange={updateMode} focusEditor={props.focusEditor} />
134+
<FormatJsonButton editorMode={props.editorMode} focusEditor={props.focusEditor} formatJson={formatJson} />
135+
<div style={{ float: 'right' }}>
136+
<PublishButton publish={props.publish} focusEditor={props.focusEditor} />
139137
</div>
140138
</div>
141-
),
142-
[props.editorMode]
139+
</div>
143140
)
144-
}
141+
})
145142

146143
const FormatJsonButton = React.memo(function FormatJsonButton(props: {
147144
editorMode: string
@@ -166,7 +163,7 @@ const FormatJsonButton = React.memo(function FormatJsonButton(props: {
166163
)
167164
})
168165

169-
const PublishButton = (props: { publish: () => void; focusEditor: () => void }) => {
166+
const PublishButton = memo(function PublishButton(props: { publish: () => void; focusEditor: () => void }) {
170167
const handleClickPublish = useCallback(
171168
(e: React.MouseEvent) => {
172169
e.stopPropagation()
@@ -175,22 +172,19 @@ const PublishButton = (props: { publish: () => void; focusEditor: () => void })
175172
[props.publish]
176173
)
177174

178-
return useMemo(
179-
() => (
180-
<Button
181-
variant="contained"
182-
size="small"
183-
color="primary"
184-
onClick={handleClickPublish}
185-
onFocus={props.focusEditor}
186-
id="publish-button"
187-
>
188-
<Navigation style={{ marginRight: '8px' }} /> Publish
189-
</Button>
190-
),
191-
[handleClickPublish]
175+
return (
176+
<Button
177+
variant="contained"
178+
size="small"
179+
color="primary"
180+
onClick={handleClickPublish}
181+
onFocus={props.focusEditor}
182+
id="publish-button"
183+
>
184+
<Navigation style={{ marginRight: '8px' }} /> Publish
185+
</Button>
192186
)
193-
}
187+
})
194188

195189
const mapDispatchToProps = (dispatch: any) => {
196190
return {

0 commit comments

Comments
 (0)