Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

268
Views
window.onblur event in react js not getting invoked in android webview

Code given below works perfectly in PC, Laptop, Tab, and Mobile Browsers. This code detects whether the user is opening another tab or other document or losing focus of the current browser window. But if we build a web app from this code using android web-view then this does not work at all.

import React,{useEffect} from 'react';

function App() {
useEffect(() =>
{
const onBlurCallback = () => onBlur();
window.addEventListener('blur', onBlurCallback);
return () =>
{
window.removeEventListener('blur', onBlurCallback);
};
}, []);

return (
<div className="App">

</div>
);
}

function onBlur()
{
alert('hello');
}

export default App;

Please suggest a solution that will work in the android web-view also.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You don't need to use addEventListner for the blur like that in React. You can try it like this:

<input type="text" onBlur={()=> //... your function here} />
about 4 years ago · Juan Pablo Isaza Report

0

Recommend Link : Official Document

You can use the onBlur function by adding it as an attribute of the <input />.

function Example() {
  return (
    <input
      onBlur={(e) => {
        console.log('Triggered because this input lost focus');
      }}
      placeholder="onBlur is triggered when you click this input and then you click outside of it."
    />
  )
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!