Created
May 14, 2015 03:42
-
-
Save zackify/8270dd200b51282076ec to your computer and use it in GitHub Desktop.
isMounted Module
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
import React from 'react'; | |
export default function isMounted(component) { | |
// exceptions for flow control :( | |
try { | |
React.findDOMNode(component); | |
return true; | |
} catch (e) { | |
// Error: Invariant Violation: Component (with keys: props,context,state,refs,_reactInternalInstance) contains `render` method but is not mounted in the DOM | |
return false; | |
} | |
}; | |
//inside your component import this file ^ and do | |
isMounted(this) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment