带有特定数量的样式化实例的样式化组件错误

时间:2020-08-10 15:28:09

标签: javascript reactjs typescript styled-components

从样式化组件运行我的笑话测试时,我当前收到以下错误:

尝试插入新样式标签,但给定的Node已卸载!

  • 您是否正在使用未安装的自定义目标?
  • 您的文档没有有效的head元素吗?
  • 您是否不小心手动删除了样式标签?

这是下面的代码:

import * as React from "react";
import { Heading } from "./heading";
import { MTButton } from "mtbutton";
import styled from "styled-components";

type FactsProperties = {
    facts: any;
    title: string;
    articleURL: string;
};

type FactsState = {
    currentFact: any;
};

const FactsDiv = styled.div`
    text-align: center;
`;

const FactDiv = styled.div`
    display: flex;
`;

const PageButton = styled.button`
    cursor: pointer;
`;

当我删除底部的PageButton声明时,它可以工作。在收到上述错误之前,似乎只能在此文件中放置2个样式声明。据我所知,我已经为所有依赖项固定了4.4.1样式的组件。

1 个答案:

答案 0 :(得分:0)

似乎答案在于玩笑如何处理模块。将以下内容放入jest.config.js后,即可恢复正常工作:

  moduleDirectories: [
    "<rootDir>/node_modules",
    "node_modules"
  ],