Skip to content

Commit

Permalink
fix: Fix style issue caused by placeholder. (#114 #131)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Nov 7, 2022
1 parent 23576d8 commit e856815
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ export default React.forwardRef<HTMLTextAreaElement, TextareaCodeEditorProps>((p
} = props;

const [value, setValue] = useState(props.value || '');
useEffect(
() => setValue(props.value || ''),
[props.value]
);
useEffect(() => setValue(props.value || ''), [props.value]);
const textRef = useRef<HTMLTextAreaElement>(null);
useImperativeHandle<HTMLTextAreaElement, HTMLTextAreaElement>(ref, () => textRef.current!);

Expand All @@ -63,11 +60,11 @@ export default React.forwardRef<HTMLTextAreaElement, TextareaCodeEditorProps>((p
() =>
processHtml(
`<pre aria-hidden=true><code ${language && value ? `class="language-${language}"` : ''} >${htmlEncode(
String(value || placeholder || ''),
String(value || ''),
)}</code><br /></pre>`,
rehypePlugins,
),
[value, placeholder, language, rehypePlugins],
[value, language, rehypePlugins],
);
const preView = useMemo(
() => (
Expand Down

0 comments on commit e856815

Please sign in to comment.