<commit_before>import Vue from 'vue';
import React from 'react';
import ReactDom from 'react-dom';

const registerRoute = (navConfig, isReact) => {
  let route = [];
  let navs = navConfig['zh-CN'];
  navs.forEach(nav => {
    if (nav.groups) {
      nav.groups.forEach(group => {
        group.list.forEach(nav => {
          addRoute(nav);
        });
      });
    } else if (nav.children) {
      nav.children.forEach(nav => {
        addRoute(nav);
      });
    } else {
      addRoute(nav);
    }
  });

  function addRoute(page) {
    const componentName = 'demo-page-' + page.path.slice(1);
    let filePath;
    if (page.filePath) {
      filePath = page.filePath;
    } else {
      let fileName = page.path + (isReact ? '.js' : '.md');
      filePath = './examples' + fileName;
    }

    if (isReact) {
      route.push({
        path: '/component' + page.path,
        component: Vue.component(componentName, {
          render(createElement) {
            return createElement('div', {
              'class': {
                'react-doc-page-content': true
              }
            });
          },
          mounted() {
            page.filePath().then((res) => {
              ReactDom.render(
                React.createElement(res),
                this.$el
              );
            });
          }
        })
      });
    } else {
      route.push({
        path: '/component' + page.path,
        component: function(resolve) {
          require([`${filePath}`], resolve);
        }
      });
    }
  }

  // console.log(route);

  return route;<commit_msg>fix: unmount react node before vue unmounts<commit_after>import Vue from 'vue';
import React from 'react';
import ReactDom from 'react-dom';

const registerRoute = (navConfig, isReact) => {
  let route = [];
  let navs = navConfig['zh-CN'];
  navs.forEach(nav => {
    if (nav.groups) {
      nav.groups.forEach(group => {
        group.list.forEach(nav => {
          addRoute(nav);
        });
      });
    } else if (nav.children) {
      nav.children.forEach(nav => {
        addRoute(nav);
      });
    } else {
      addRoute(nav);
    }
  });

  function addRoute(page) {
    const componentName = 'demo-page-' + page.path.slice(1);
    let filePath;
    if (page.filePath) {
      filePath = page.filePath;
    } else {
      let fileName = page.path + (isReact ? '.js' : '.md');
      filePath = './examples' + fileName;
    }

    if (isReact) {
      route.push({
        path: '/component' + page.path,
        component: Vue.component(componentName, {
          render(createElement) {
            return createElement('div', {
              'class': {
                'react-doc-page-content': true
              }
            });
          },
          mounted() {
            page.filePath().then((res) => {
              ReactDom.render(
                React.createElement(res),
                this.$el
              );
            });
          },
          beforeDestroy() {
            ReactDom.unmountComponentAtNode(this.$el);
          }
        })
      });
    } else {
      route.push({
        path: '/component' + page.path,
        component: function(resolve) {
          require([`${filePath}`], resolve);
        }
      });
    }
  }

  // console.log(route);

  return route;
{'fraction_non_alphanumeric': 0.1532404603270745, 'fraction_numerical': 0.0006056935190793458, 'mean_word_length': 1.5905882352941176, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5970466', 'n_tokens_mistral': 992, 'n_tokens_neox': 989, 'n_words': 181}