Skip to content

Commit 6bff633

Browse files
committed
refactor: Use JSX rather than React.createElement
1 parent aaeeb3f commit 6bff633

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

package/src/components/Message/MessageSimple/utils/renderText.tsx

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -182,20 +182,17 @@ export const renderText = <
182182
}
183183
};
184184

185-
state.withinLink = true;
186-
const link = React.createElement(
187-
Text,
188-
{
189-
key: state.key,
190-
onLongPress,
191-
onPress,
192-
style: styles.autolink,
193-
suppressHighlighting: true,
194-
},
195-
output(node.content, state),
185+
return (
186+
<Text
187+
key={state.key}
188+
onLongPress={onLongPress}
189+
onPress={onPress}
190+
style={styles.autolink}
191+
suppressHighlighting={true}
192+
>
193+
{output(node.content, { ...state, withinLink: true })}
194+
</Text>
196195
);
197-
state.withinLink = false;
198-
return link;
199196
};
200197

201198
const mentionedUsers = Array.isArray(mentioned_users)
@@ -230,15 +227,10 @@ export const renderText = <
230227
}
231228
};
232229

233-
return React.createElement(
234-
Text,
235-
{
236-
key: state.key,
237-
onLongPress,
238-
onPress,
239-
style: styles.mentions,
240-
},
241-
Array.isArray(node.content) ? node.content[0]?.content || '' : output(node.content, state),
230+
return (
231+
<Text key={state.key} onLongPress={onLongPress} onPress={onPress} style={styles.mentions}>
232+
{Array.isArray(node.content) ? node.content[0].content || '' : output(node.content, state)}
233+
</Text>
242234
);
243235
};
244236

0 commit comments

Comments
 (0)