Skip to content

Instantly share code, notes, and snippets.

@zackify
Created May 14, 2015 03:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zackify/8270dd200b51282076ec to your computer and use it in GitHub Desktop.
Save zackify/8270dd200b51282076ec to your computer and use it in GitHub Desktop.
isMounted Module
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