Skip to content

Commit

Permalink
fixed string ref deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
myxmaster committed Jun 13, 2024
1 parent 1c97cdd commit a24b80c
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 27 deletions.
1 change: 0 additions & 1 deletion components/Modals/AndroidNfcModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export default class AndroidNfcModal extends React.Component<
backButtonClose={false}
backdropPressToClose={false}
position="bottom"
ref="modal"
>
<View
style={{
Expand Down
1 change: 0 additions & 1 deletion components/Modals/ExternalLinkModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export default class ExternalLinkModal extends React.Component<
}}
onClosed={() => toggleExternalLinkModal(false)}
position="bottom"
ref="modal"
>
<View
style={{
Expand Down
1 change: 0 additions & 1 deletion components/Modals/InfoModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export default class InfoModal extends React.Component<InfoModalProps, {}> {
minHeight: 200
}}
onClosed={() => toggleInfoModal()}
ref="modal"
>
<View
style={{
Expand Down
6 changes: 4 additions & 2 deletions views/OpenChannel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ export default class OpenChannel extends React.Component<
});
};

private scrollViewRef = React.createRef<ScrollView>();

render() {
const {
ChannelsStore,
Expand Down Expand Up @@ -366,7 +368,7 @@ export default class OpenChannel extends React.Component<
flex: 1
}}
keyboardShouldPersistTaps="handled"
ref="_scrollView"
ref={this.scrollViewRef}
>
{!!suggestImport && (
<View style={styles.clipboardImport}>
Expand Down Expand Up @@ -974,7 +976,7 @@ export default class OpenChannel extends React.Component<
color: 'white'
}}
onPress={() => {
this.refs._scrollView.scrollTo({
this.scrollViewRef.current?.scrollTo({
y: 0,
animated: true
});
Expand Down
8 changes: 5 additions & 3 deletions views/Receive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,8 @@ export default class Receive extends React.Component<
});
};

private modalBoxRef = React.createRef<ModalBox>();

render() {
const {
InvoicesStore,
Expand Down Expand Up @@ -1055,7 +1057,7 @@ export default class Receive extends React.Component<
);

const SettingsButton = () => (
<TouchableOpacity onPress={() => this.refs.modal.open()}>
<TouchableOpacity onPress={() => this.modalBoxRef.current?.open()}>
<Gear
style={{ alignSelf: 'center' }}
fill={themeColor('text')}
Expand Down Expand Up @@ -2662,7 +2664,7 @@ export default class Receive extends React.Component<
swipeToClose={true}
backButtonClose={true}
position="bottom"
ref="modal"
ref={this.modalBoxRef}
>
<Text
style={{
Expand All @@ -2681,7 +2683,7 @@ export default class Receive extends React.Component<
onPress={() => {
InvoicesStore.clearAddress();
this.setState({ addressType: d.value });
this.refs.modal.close();
this.modalBoxRef.current?.close();
}}
style={{
backgroundColor: themeColor('secondary'),
Expand Down
28 changes: 12 additions & 16 deletions views/Routing/SetFees.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ interface SetFeesProps {
@inject('ChannelsStore', 'FeeStore', 'NodeInfoStore')
@observer
export default class SetFees extends React.PureComponent<SetFeesProps, {}> {
private scrollViewRef = React.createRef<ScrollView>();

render() {
const { ChannelsStore, FeeStore, NodeInfoStore, navigation, route } =
this.props;
Expand Down Expand Up @@ -90,7 +92,7 @@ export default class SetFees extends React.PureComponent<SetFeesProps, {}> {
navigation={navigation}
/>

<ScrollView ref="_scrollView">
<ScrollView ref={this.scrollViewRef}>
<View style={{ padding: 15 }}>
{channel && policy && BackendUtils.isLNDBased() && (
<SetFeesForm
Expand All @@ -107,11 +109,9 @@ export default class SetFees extends React.PureComponent<SetFeesProps, {}> {
}`}
channelPoint={channelPoint}
channelId={channelId}
setFeesCompleted={() => {
(
this.refs._scrollView as ScrollView
).scrollToEnd();
}}
setFeesCompleted={() =>
this.scrollViewRef.current?.scrollToEnd()
}
/>
)}
{channel && !BackendUtils.isLNDBased() && (
Expand All @@ -128,20 +128,16 @@ export default class SetFees extends React.PureComponent<SetFeesProps, {}> {
}
channelPoint={channelPoint}
channelId={channelId}
setFeesCompleted={() => {
(
this.refs._scrollView as ScrollView
).scrollToEnd();
}}
setFeesCompleted={() =>
this.scrollViewRef.current?.scrollToEnd()
}
/>
)}
{!channel && (
<SetFeesForm
setFeesCompleted={() => {
(
this.refs._scrollView as ScrollView
).scrollToEnd();
}}
setFeesCompleted={() =>
this.scrollViewRef.current?.scrollToEnd()
}
/>
)}
</View>
Expand Down
8 changes: 5 additions & 3 deletions views/Settings/InvoicesSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ export default class InvoicesSettings extends React.Component<
/>
);

private modalBoxRef = React.createRef<ModalBox>();

render() {
const { navigation, SettingsStore } = this.props;
const {
Expand Down Expand Up @@ -135,7 +137,7 @@ export default class InvoicesSettings extends React.Component<
];

const SettingsButton = () => (
<TouchableOpacity onPress={() => this.refs.modal.open()}>
<TouchableOpacity onPress={() => this.modalBoxRef.current?.open()}>
<Gear
style={{ alignSelf: 'center' }}
fill={themeColor('text')}
Expand Down Expand Up @@ -441,7 +443,7 @@ export default class InvoicesSettings extends React.Component<
swipeToClose={true}
backButtonClose={true}
position="bottom"
ref="modal"
ref={this.modalBoxRef}
>
<Text
style={{
Expand Down Expand Up @@ -471,7 +473,7 @@ export default class InvoicesSettings extends React.Component<
showCustomPreimageField
}
});
this.refs.modal.close();
this.modalBoxRef.current?.close();
}}
style={{
backgroundColor: themeColor('secondary'),
Expand Down

0 comments on commit a24b80c

Please sign in to comment.