Skip to content

Commit 648445f

Browse files
committed
fix: remove componentShouldUpdate
1 parent b3e70b8 commit 648445f

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

hello-world/react/README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,7 @@ class VideoCapture extends React.Component {
200200
this.cameraEnhancer?.dispose();
201201
} catch (_) {}
202202
}
203-
204-
shouldComponentUpdate() {
205-
// Never update UI after mount, sdk use native way to bind event, update will remove it.
206-
return false;
207-
}
208-
203+
209204
render() {
210205
return (
211206
<div>

hello-world/react/src/components/VideoCapture/VideoCapture.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const componentDestroyedErrorMsg = "VideoCapture Component Destroyed";
99

1010
class VideoCapture extends React.Component {
1111
state = {
12-
resultText: ""
12+
resultText: "",
1313
};
1414
cameraViewContainer: React.RefObject<HTMLDivElement> = React.createRef();
1515

@@ -47,13 +47,13 @@ class VideoCapture extends React.Component {
4747
this.cvRouter.addResultReceiver({
4848
onDecodedBarcodesReceived: (result) => {
4949
if (!result.barcodeResultItems.length) return;
50-
50+
5151
let _resultText = "";
5252
console.log(result);
5353
for (let item of result.barcodeResultItems) {
5454
_resultText += `${item.formatString}: ${item.text}\n\n`;
5555
}
56-
this.setState({resultText: _resultText})
56+
this.setState({ resultText: _resultText });
5757
},
5858
});
5959

@@ -102,15 +102,10 @@ class VideoCapture extends React.Component {
102102
} catch (_) {}
103103
}
104104

105-
shouldComponentUpdate() {
106-
// Never update UI after mount, sdk use native way to bind event, update will remove it.
107-
return false;
108-
}
109-
110105
render() {
111106
return (
112107
<div>
113-
<div ref={this.cameraViewContainer} style={{ width: "100%", height: "70vh" }}></div>
108+
<div ref={this.cameraViewContainer} style={{ width: "100%", height: "70vh" }}></div>
114109
<br />
115110
Results:
116111
<div className="results">{this.state.resultText}</div>

0 commit comments

Comments
 (0)