1- import React , { useRef } from 'react' ;
1+ import React , { useMemo , useRef } from 'react' ;
22
33import { TextInput as RNTextInput , StyleProp , TextInputProps , TextStyle , View } from 'react-native' ;
44
@@ -36,25 +36,34 @@ const HighlightableTextInput: React.FC<HighlightableTextInputProps> = ({
3636 const highlightColor = currentColors . primary ;
3737 const textInputRef = useRef < RNTextInput > ( null ) ;
3838
39- const highlightStyle = { fontWeight : 'bold' as const , color : highlightColor } ;
39+ const highlightStyle = useMemo (
40+ ( ) => ( { fontWeight : 'bold' as const , color : highlightColor } ) ,
41+ [ highlightColor ]
42+ ) ;
4043
41- const triggersConfig = {
42- mention : {
43- trigger : '@' ,
44- textStyle : highlightStyle ,
45- } ,
46- } ;
44+ const triggersConfig = useMemo (
45+ ( ) => ( {
46+ mention : {
47+ trigger : '@' ,
48+ textStyle : highlightStyle ,
49+ } ,
50+ } ) ,
51+ [ highlightStyle ]
52+ ) ;
4753
48- const patternsConfig = {
49- mention : {
50- pattern : / ( @ \w + ) / ,
51- textStyle : highlightStyle ,
52- } ,
53- hashtag : {
54- pattern : / ( # \w + ) / ,
55- textStyle : highlightStyle ,
56- } ,
57- } ;
54+ const patternsConfig = useMemo (
55+ ( ) => ( {
56+ mention : {
57+ pattern : / ( @ \w + ) / ,
58+ textStyle : highlightStyle ,
59+ } ,
60+ hashtag : {
61+ pattern : / ( # \w + ) / ,
62+ textStyle : highlightStyle ,
63+ } ,
64+ } ) ,
65+ [ highlightStyle ]
66+ ) ;
5867
5968 const { textInputProps, triggers } = useMentions ( {
6069 value,
@@ -72,6 +81,7 @@ const HighlightableTextInput: React.FC<HighlightableTextInputProps> = ({
7281 placeholderTextColor = { placeholderTextColor }
7382 style = { style }
7483 multiline = { multiline }
84+ scrollEnabled = { false }
7585 textAlignVertical = { textAlignVertical }
7686 testID = { testID }
7787 autoCorrect = { false }
0 commit comments