Skip to content

Commit 1bade58

Browse files
committed
1 parent c6b6725 commit 1bade58

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/containers/write/PublishURLSettingContainer.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { RootState } from '../../modules';
44
import PublishURLSetting from '../../components/write/PublishURLSetting';
55
import { escapeForUrl } from '../../lib/utils';
66
import { changeUrlSlug } from '../../modules/write';
7+
import { useMount } from 'react-use';
78

89
interface OwnProps {}
910
type StateProps = ReturnType<typeof mapStateToProps>;
@@ -28,16 +29,21 @@ const PublishURLSettingContainer: React.FC<PublishURLSettingContainerProps> = ({
2829
changeUrlSlug,
2930
}) => {
3031
const defaultUrlSlug = escapeForUrl(title);
31-
const urlSlugToShow = urlSlug || defaultUrlSlug;
3232
const onChangeUrlSlug = useCallback(
3333
(urlSlug: string) => changeUrlSlug(urlSlug),
3434
[changeUrlSlug],
3535
);
36+
37+
useMount(() => {
38+
if (!urlSlug) {
39+
changeUrlSlug(defaultUrlSlug);
40+
}
41+
});
3642
if (!username) return null;
3743
return (
3844
<PublishURLSetting
3945
username={username}
40-
urlSlug={urlSlugToShow}
46+
urlSlug={urlSlug}
4147
onChangeUrlSlug={onChangeUrlSlug}
4248
/>
4349
);

0 commit comments

Comments
 (0)