diff --git a/react_ujs/index.js b/react_ujs/index.js index 0ef70a5a3..84e9665ea 100644 --- a/react_ujs/index.js +++ b/react_ujs/index.js @@ -73,6 +73,11 @@ var ReactRailsUJS = { useContext: function(requireContext) { this.getConstructor = constructorFromRequireContextWithGlobalFallback(requireContext) }, + + // Called after React unmounts component at `node` + // Override this function to perform any cleanup + // the default function does nothing + onComponentUnmountAtNode: function (node) {}, // Render `componentName` with `props` to a string, // using the specified `renderFunction` from `react-dom/server`. @@ -135,6 +140,7 @@ var ReactRailsUJS = { for (var i = 0; i < nodes.length; ++i) { var node = nodes[i]; ReactDOM.unmountComponentAtNode(node); + ReactRailsUJS.onComponentUnmountAtNode(node); } },