Skip to content

Input Area disappers on source #283

Answered by smitbarmase
Zonalds asked this question in Q&A
Discussion options

You must be logged in to vote

Adding a dependency to theuseCallback, seems to break it. I found the workaround that is, using useRef.

const RichText = ({
	id,
	mentions,
	...props
}: RichTextProps) => {
	const mentionsRef = useRef<Mention[]>([]);

	useEffect(() => {
		mentionsRef.current = mentions;
	}, [mentions]);

	return (
			<ReactQuill
				modules={{
					mention: {
						allowedChars: /^[A-Za-z\sÅÄÖåäö]*$/,
						mentionDenotationChars: ["@"],
						source: useCallback(
							(
								searchTerm: string,
								renderList: (arg0: Mention[] | undefined, arg1: string) => void,
								mentionChar: string
							) => {
								let values;
								if (mentionChar === "@") {
									values = mentionsRef.current;

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by csculley
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #263 on July 16, 2023 08:02.