Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TS migration] Migrate 'updatePropsPaperWorklet' lib to TypeScript #31546

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/libs/updatePropsPaperWorklet/index.js

This file was deleted.

13 changes: 0 additions & 13 deletions src/libs/updatePropsPaperWorklet/index.native.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';
import {View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import {runOnJS, useAnimatedRef} from 'react-native-reanimated';
import {runOnJS, setNativeProps, useAnimatedRef} from 'react-native-reanimated';
import _ from 'underscore';
import AttachmentModal from '@components/AttachmentModal';
import EmojiPickerButton from '@components/EmojiPicker/EmojiPickerButton';
Expand All @@ -24,7 +24,6 @@ import getDraftComment from '@libs/ComposerUtils/getDraftComment';
import * as DeviceCapabilities from '@libs/DeviceCapabilities';
import getModalState from '@libs/getModalState';
import * as ReportUtils from '@libs/ReportUtils';
import updatePropsPaperWorklet from '@libs/updatePropsPaperWorklet';
import willBlurTextInputOnTapOutsideFunc from '@libs/willBlurTextInputOnTapOutside';
import ParticipantLocalTime from '@pages/home/report/ParticipantLocalTime';
import reportActionPropTypes from '@pages/home/report/reportActionPropTypes';
Expand Down Expand Up @@ -348,13 +347,10 @@ function ReportActionCompose({
return;
}

const viewTag = animatedRef();
const viewName = 'RCTMultilineTextInputView';
const updates = {text: ''};
// We are setting the isCommentEmpty flag to true so the status of it will be in sync of the native text input state
runOnJS(setIsCommentEmpty)(true);
runOnJS(resetFullComposerSize)();
updatePropsPaperWorklet(viewTag, viewName, updates); // clears native text input on the UI thread
setNativeProps(animatedRef, {text: ''}); // clears native text input on the UI thread
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setNativeProps for react-native is deprecated.

To migrate to Fabric architecture, we have to remove all usages of setNativeProps.

Could we confirm if it's OK to use setNativeProps from react-native-reanimated?

Copy link
Contributor

@tomekzaw tomekzaw Dec 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setNativeProps from react-native-reanimated is something different than setNativeProps from react-native; it works on the UI thread and it doesn't have some of the problems of setNativeProps from react-native, see docs here: https://docs.swmansion.com/react-native-reanimated/docs/advanced/setNativeProps/

It's used here as a workaround to fix an underlying issue in RN's TextInput component until we have a better solution.

Finally, setNativeProps from react-native-reanimated in fact a public wrapper on _updatePropsPaper (which is meant to be used only internally) so this PR does not introduce any functional changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this answer your question? @rushatgabhane 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes thank you so much, Tomek!!

runOnJS(submitForm)();
}, [isSendDisabled, resetFullComposerSize, submitForm, animatedRef, isReportReadyForDisplay]);

Expand Down
Loading