Skip to content

Commit

Permalink
fix: explicit state
Browse files Browse the repository at this point in the history
  • Loading branch information
WindRunnerMax committed Sep 30, 2024
1 parent f6ef963 commit 2fbc926
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions apps/www/src/registry/default/plate-ui/mention-element.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect } from 'react';
import React from 'react';

import type { TMentionElement } from '@udecode/plate-mention';

Expand All @@ -8,6 +8,8 @@ import { PlateElement, useElement } from '@udecode/plate-common/react';
import { IS_APPLE } from '@udecode/utils';
import { useFocused, useSelected } from 'slate-react';

import { useMounted } from '@/hooks/use-mounted';

export const MentionElement = withRef<
typeof PlateElement,
{
Expand All @@ -19,12 +21,7 @@ export const MentionElement = withRef<
const element = useElement<TMentionElement>();
const selected = useSelected();
const focused = useFocused();
const [isMacEnv, setIsMacEnv] = React.useState(false);

useEffect(() => {
// Avoid ssr hydration mismatch
setIsMacEnv(IS_APPLE);
}, []);
const mounted = useMounted();

return (
<PlateElement
Expand All @@ -42,7 +39,7 @@ export const MentionElement = withRef<
contentEditable={false}
{...props}
>
{isMacEnv ? (
{mounted && IS_APPLE ? (
// Mac OS IME https://github.com/ianstormtaylor/slate/issues/3490
<React.Fragment>
{children}
Expand Down

0 comments on commit 2fbc926

Please sign in to comment.