我正在使用带有 antd 的 react hook 组件。为表设置列时,渲染函数给我一个 ESLint 错误:
ESLint:组件定义缺少 displayName (react/display-name)
我试过将 displayName 添加到对象中,但这不起作用。
这是代码:
const columns_payment_summary_table = [
{
title: FooConstants.LABEL_QUANTITY_SELECTED,
dataIndex: 'group',
key: 'group',
render: text => (
<span>{getCountForCountry(text)}</span>
),
}
]
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮忙吗?
这是完整的组件代码(只是相关位)
import * as FooConstants from './constants'
import {connect} from 'react-redux'
import React, {useState, useEffect} from 'react'
import {Card, Table} from 'antd'
import PropTypes from 'prop-types'
const propTypes = {
foos: PropTypes.object.isRequired,
}
function Foos(props) {
const [selectedFooRows, setSelectedFooRows] = useState([])
useEffect(() => { …Run Code Online (Sandbox Code Playgroud) 在单元测试中,我想测试父组件是否成功呈现了其子组件。这是代码:
describe('Parent Component', () => {
it('renders Child component', () => {
const wrapper = shallow(<Parent store={store} />);
expect(wrapper.find(Child).length).toEqual(1);
});
});
Run Code Online (Sandbox Code Playgroud)
上级:
const Parent = observer(({ store }) => {
const bookList = toJS(store.planets);
return (
<div>
<div className={style.planet_container}>
{bookList.map(book => {
return <Child key={book.name} name={book.name} />;
})}
</div>
</div>
);
});
Run Code Online (Sandbox Code Playgroud)
上面的代码是从这里获取的,但是它不起作用。我收到以下错误:
预期1,收到0'
我要去哪里错了?我在Jest 23.1.0中使用酶3.3。