Suppose I have a component that has two functions which are run when the app is started so when I switch app in responsive width and that width is mobile so i want to run only one function in that the second one has to be removed
does anyone can help??
CodePudding user response:
Just get window width and set if statement.
const width = window.innerWidth
if (width === 400) {
runFunction()
}
or
const width = window.innerWidth
const runFunction = () => {
if (width === 400) {
// ...function logic
return
}
return
}