Warning of require cycle using code similar to the example
See original GitHub issueUsing the code as example, this warning always appear:
Require cycle: node_modules/vision-camera-code-scanner/src/index.ts -> node_modules/vision-camera-code-scanner/src/hook.tsx -> node_modules/vision-camera-code-scanner/src/index.ts
The code being used:
import React from "react";
import { Camera, useCameraDevices } from "react-native-vision-camera";
import { useScanBarcodes, BarcodeFormat } from "vision-camera-code-scanner";
export function CameraWrapper(props) {
const [hasPermission, setHasPermission] = React.useState(false);
const devices = useCameraDevices();
const device = devices.back;
const [frameProcessor, barcodes] = useScanBarcodes([BarcodeFormat.QR_CODE], {
checkInverted: true
});
React.useEffect(() => {
(async () => {
const status = await Camera.requestCameraPermission();
setHasPermission(status === "authorized");
})();
}, [props]);
React.useEffect(() => {
if (barcodes.length === 0) return;
console.log(barcodes);
}, [barcodes]);
return (
device != null &&
hasPermission && (
<Camera
style={props.style}
device={device}
photo={true}
audio={false}
isActive={true}
frameProcessor={frameProcessor}
frameProcessorFps={props.fps || 5}
/>
)
);
}
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:7
Top Results From Across the Web
Require cycles are allowed, but can result in uninitialized ...
js This is what triggers the Require cycle warning because a module that was imported from one place, is then rendering and asking...
Read more >The code review feature seems too expensive to run on every ...
The code review feature seems too expensive to run on every PR automatically (to me): $0.75 per 100 lines of code. From their...
Read more >Getting Started with Victory Native
If you are building a project with native code, you will need to link the native ... Native apps (on both iOS and...
Read more >Initialization error | Database Hub - Back4App
js Require cycles are allowed, but can result in uninitialized values. Consider refactoringto remove the need for a cycle. TypeError: undefined is not...
Read more >React and Redux: Require cycle (how to get rid of it?) - Reddit
React throws me a warning like, come on man, don't do that. ... In Frontend JavaScript In The Real World (With React Code...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes correct, this should be fixed here. What I’m suggesting is a palliative fix for your own project while the library doesn’t fix this themselves. So you don’t need to keep that warning in your project.
There is a forecast for the release of this release with the correction?