score:2
Accepted answer
you need to change the order of function declaration. you can not call const
variables before they were declared.
//passing image from my react component
const facedetector = (image) => {
const imageref = image;
// this function should detect the face from imageref and should console the size of detector
const handleimage = async () => {
const detections = await faceapi
.detectsingleface(imageref, new faceapi.tinyfacedetectoroptions())
console.log(`width ${detections.box._width} and height ${detections.box._height}`);
}
const loadmodels = async () => {
// models are present in public and they are getting loaded
const model_url = process.env.public_url + "/models";
promise.all([
faceapi.nets.tinyfacedetector.loadfromuri(model_url),
faceapi.nets.facelandmark68net.loadfromuri(model_url),
faceapi.nets.facerecognitionnet.loadfromuri(model_url),
faceapi.nets.faceexpressionnet.loadfromuri(model_url)
])
// this is rising the issue. i want to call this function after my models loaded so it can detect face
.then(handleimage)
.catch((e) => console.error(e));
};
loadmodels();
}
Source: stackoverflow.com
Related Query
- react, how to call a function inside then block before initializing it or any proper way?
- React - How do you call a function from inside another function
- How to Separate Jsx inside render function into a separate file in ES6? or any other solution in react to separate the Logic and presentation?
- React how to properly call a component function inside render()
- How to call a onclick function inside a Template literal in React js
- How to call react router DOM link inside a function call/manually
- How to call a user defined function to print inside a <td> in react
- How to call a function of a react component in other js files inside the project
- How to call function from App.js file inside public folder in React JS
- How to call a function defined inside react component in a typescript class?
- How can I call a function that set sets an outside variable inside a custom component in React Native?
- How can we call a function before refreshing a page using react
- How to call event target inside a function with enzyme - React
- How to call a function inside the const click function using React Redux?
- How to call a React component function from inside a javascript function?
- React - how to pass a prop into a class function call that is then accessed in componentDidMount function
- How to test a function call after state receive value inside expression in React function component using Jest
- React - How to call a function which is inside another callback function
- How to call loading function with React useEffect only once
- How to Call a Function inside a Render in React/Jsx
- How to call an async function inside a UseEffect() in React?
- How to call a function every minute in a React component?
- How to loop inside map function using jsx format React JS
- How do you get any useful call stack information when debugging react native?
- React: How to add onChange functionality inside of Function component using React Hooks? Need onClick event from a checkbox to influence input state
- How can I use an axios get call inside a Context provider in react
- How to call a component function on other component, but from the other component ? React
- React - Call props function inside of a components function
- How to not use setState inside render function in React
- How to use React Context inside function of Class component
More Query from same tag
- Re-initializing class on redirect
- Why my state argument when creating my Redux-Reducer is not being updated?
- how to apply carousel in cards reactjs
- Why are two of my checkbox values not working?
- React app not sending files to php server with Ajax
- Ejecting from CRA to share components the shared directory are not linted
- Why does error appear when I try to iterate array of objects in my react.js component?
- Language object prop to pass in the react component
- How to pass props into jest test in React
- Changed style onClick applies to all the ListItems instead of single ListItems
- ReactJs : What is the proper way of accessing the state data in the root component where the link between React and Redux has been implemented?
- Reach child does not update when state changes
- Reading data of a DataContext object
- Bold active menu after refreshing the page
- Jest test (ReferenceError: google is not defined) ReactJS and Google Charts
- Rendering comma separated list of links
- Cross origin error thrown on GraphQL subscription
- React Native two time taps required for onPress event inside scrollview
- How can I get consistent line heights in view and edit mode?
- How to run two React projects on one domain?
- Encountered "Error: Material-UI: capitalize(string) expects a string argument." when using snackbar in React Material-UI
- NextJS React - WebpackError: window is not defined
- disable all click synthesis events of react
- Spread syntax gives error when copying react component properties
- Could not find store in either context or props
- Passing onClick from child to parent
- problems with babel react preset and react-dom
- React function called multiple time
- how to access from app component to my react reusable table cell data
- How to force re-render if map value changes?