PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: DevExpress/devextreme-react (js)

Issue:
List doesn't unmount old templates if they had dynamic root element
### Issue Type
bug report

#### Steps to Reproduce
1. Init List with ItemComponent option and 2 data items
2. Change ItemComponent's root element after 1s (loading simulation)
3. Change List's data items after 5s (filtration simulation)

#### Current Behavior
ReactList generates 2 templates after step 1 and 2 templates after step 2

#### Expected Behavior
ReactList generates 2 templates after step 1, removes 2 templates and generates 2 templates after step 2.

#### Demo
https://stackblitz.com/edit/devextreme-react-1dzhv6?file=index.js

### Environment Details
devextreme 18.1.1-pre-18093
devextreme-react 18.1.1-alpha.4
react 16.3.0


Pull request:
Fix template removing
fix #87 

Patch:
diff --git a/src/core/template-wrapper.ts b/src/core/template-wrapper.ts
index 763f031..4132d6a 100644
--- a/src/core/template-wrapper.ts
+++ b/src/core/template-wrapper.ts
@@ -30,7 +30,12 @@ class TemplateWrapper extends React.PureComponent<IWrapperProps, any> {
     }
 
     public componentDidMount() {
-        const element = ReactDOM.findDOMNode(this);
+        const templateElement = ReactDOM.findDOMNode(this);
+        const templateParent = templateElement.parentNode;
+
+        const isGridRow = templateParent && templateParent.nodeName !== "DIV";
+        const element = isGridRow ? templateElement : templateParent;
+
         events.one(element, DX_REMOVE_EVENT, this.props.onRemoved);
     }
 }
@@ -42,7 +47,6 @@ function wrapTemplate(
     return {
         render: (data: ITemplateData) => {
             const templateId = "__template_" + generateID();
-
             const wrapper = () =>
                 React.createElement(TemplateWrapper, {
                     content: tmplFn(data.model),


Test patch:
diff --git a/src/core/component.test.tsx b/src/core/component.test.tsx
index e35f2cd..6f48ffe 100644
--- a/src/core/component.test.tsx
+++ b/src/core/component.test.tsx
@@ -280,7 +280,7 @@ describe("templates", () => {
         renderItemTemplate({});
         expect(Object.getOwnPropertyNames(component.state("templates")).length).toBe(1);
         component.update();
-        events.triggerHandler(component.find(".template").getDOMNode(), "dxremove");
+        events.triggerHandler(component.find(".template").getDOMNode().parentNode, "dxremove");
         component.update();
         expect(Object.getOwnPropertyNames(component.state("templates")).length).toBe(0);
     });