Skip to content

Commit e5bcbf7

Browse files
committed
Update useRef usage
1 parent 8ca6c0c commit e5bcbf7

5 files changed

Lines changed: 17 additions & 37 deletions

File tree

Binary file not shown.

__tests__/receiptCard.js

Lines changed: 0 additions & 24 deletions
This file was deleted.

packages/bundle/src/adaptiveCards/Attachment/AdaptiveCardRenderer.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ const AdaptiveCardRenderer = ({ adaptiveCard, tapAction }) => {
2828

2929
const [error, setError] = useState();
3030
const contentRef = useRef();
31-
const { current: contentCurrent } = contentRef;
3231
const handleClick = useCallback(
3332
({ target }) => {
3433
// Some items, e.g. tappable text, cannot be disabled thru DOM attributes
@@ -84,7 +83,9 @@ const AdaptiveCardRenderer = ({ adaptiveCard, tapAction }) => {
8483
);
8584

8685
useLayoutEffect(() => {
87-
if (contentCurrent && adaptiveCard) {
86+
const { current } = contentRef;
87+
88+
if (current && adaptiveCard) {
8889
// Currently, the only way to set the Markdown engine is to set it thru static member of AdaptiveCard class
8990

9091
// TODO: [P3] Checks if we could make the "renderMarkdown" per card
@@ -146,15 +147,15 @@ const AdaptiveCardRenderer = ({ adaptiveCard, tapAction }) => {
146147
});
147148
}
148149

149-
const [firstChild] = contentCurrent.children;
150+
const [firstChild] = current.children;
150151

151152
if (firstChild) {
152-
contentCurrent.replaceChild(element, firstChild);
153+
current.replaceChild(element, firstChild);
153154
} else {
154-
contentCurrent.appendChild(element);
155+
current.appendChild(element);
155156
}
156157
}
157-
}, [adaptiveCard, adaptiveCardsHostConfig, contentCurrent, disabled, error, handleExecuteAction, renderMarkdown]);
158+
}, [adaptiveCard, adaptiveCardsHostConfig, contentRef, disabled, error, handleExecuteAction, renderMarkdown]);
158159

159160
return error ? (
160161
<ErrorBox message={errorMessage}>

packages/component/src/SendBox/UploadButton.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,24 @@ const UploadButton = () => {
9696
const uploadFileString = useLocalize('Upload file');
9797

9898
const inputRef = useRef();
99-
const { current } = inputRef;
10099

101100
const handleClick = useCallback(() => {
101+
const { current } = inputRef;
102+
102103
current && current.click();
103-
}, [current]);
104+
}, [inputRef]);
104105

105106
const handleFileChange = useCallback(
106107
({ target: { files } }) => {
108+
const { current } = inputRef;
109+
107110
sendFiles(files);
108111

109112
if (current) {
110113
current.value = null;
111114
}
112115
},
113-
[current, sendFiles]
116+
[inputRef, sendFiles]
114117
);
115118

116119
return (

packages/component/src/Utils/TypeFocusSink/FocusBox.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ const FocusBox = ({ children, disabled, sendFocusRef: sendFocusRefProp, ...other
2424
[patchedSendFocusRef]
2525
);
2626

27-
const { current: sendFocusCurrent } = patchedSendFocusRef;
28-
2927
const focus = useCallback(() => {
30-
sendFocusCurrent && sendFocusCurrent.focus();
31-
}, [sendFocusCurrent]);
28+
const { current } = patchedSendFocusRef;
29+
30+
current && current.focus();
31+
}, [patchedSendFocusRef]);
3232

3333
const handleKeyDownCapture = useCallback(
3434
event => {

0 commit comments

Comments
 (0)