Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3347932
D14014.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D14014.diff
View Options
diff --git a/native/chat/chat-input-bar.react.js b/native/chat/chat-input-bar.react.js
--- a/native/chat/chat-input-bar.react.js
+++ b/native/chat/chat-input-bar.react.js
@@ -361,19 +361,6 @@
return ChatInputBar.systemKeyboardShowing(this.props);
}
- componentDidMount() {
- const { isActive } = this.props;
- if (isActive) {
- this.props.addEditInputMessageListener();
- }
- }
-
- componentWillUnmount() {
- if (this.props.isActive) {
- this.props.removeEditInputMessageListener();
- }
- }
-
componentDidUpdate(prevProps: Props) {
if (
this.props.textEdited &&
@@ -1400,25 +1387,37 @@
React.useEffect(() => {
const { navigation } = props;
- if (!navigation) {
- return noop;
+
+ if (isActive) {
+ addEditInputMessageListener();
}
- const clearBeforeRemoveListener = navigation.addListener(
+ const clearBeforeRemoveListener = navigation?.addListener(
'beforeRemove',
onNavigationBeforeRemove,
);
- const clearFocusListener = navigation.addListener(
+ const clearFocusListener = navigation?.addListener(
'focus',
onNavigationFocus,
);
- const clearBlurListener = navigation.addListener('blur', onNavigationBlur);
+ const clearBlurListener = navigation?.addListener('blur', onNavigationBlur);
return () => {
- clearBeforeRemoveListener();
- clearFocusListener();
- clearBlurListener();
+ if (isActive) {
+ removeEditInputMessageListener();
+ }
+ clearBeforeRemoveListener?.();
+ clearFocusListener?.();
+ clearBlurListener?.();
};
- }, [onNavigationBeforeRemove, onNavigationBlur, onNavigationFocus, props]);
+ }, [
+ addEditInputMessageListener,
+ isActive,
+ onNavigationBeforeRemove,
+ onNavigationBlur,
+ onNavigationFocus,
+ props,
+ removeEditInputMessageListener,
+ ]);
return (
<ChatInputBar
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 1:36 PM (13 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2570922
Default Alt Text
D14014.diff (1 KB)
Attached To
Mode
D14014: [native] Move edit message listeners set up in ChatInputBar to function component
Attached
Detach File
Event Timeline
Log In to Comment