Created
February 23, 2018 17:28
-
-
Save santoshshinde2012/a4229d20cb45cec3e4b0846ed6a4a88c to your computer and use it in GitHub Desktop.
onBlur for entire react component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var HelloMessage = React.createClass({ | |
render: function() { | |
return <div tabIndex="1" onBlur={this.onBlur}> | |
Hello <input type="text" value="wat"/> | |
</div>; | |
}, | |
onBlur: function(e) { | |
var currentTarget = e.currentTarget; | |
setTimeout(function() { | |
if (!currentTarget.contains(document.activeElement)) { | |
console.log('component officially blurred'); | |
} | |
}, 0); | |
} | |
}); | |
React.render(<HelloMessage name="John" />, mountNode); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment