Reactjs 反应:Can';无法获取组件列表
在react类中,我尝试将行组件添加到列表中,以便以后需要列出某些内容时使用。它向我返回错误:Reactjs 反应:Can';无法获取组件列表,reactjs,webpack,reactstrap,Reactjs,Webpack,Reactstrap,在react类中,我尝试将行组件添加到列表中,以便以后需要列出某些内容时使用。它向我返回错误: 函数作为子函数无效。如果返回组件而不是从渲染返回组件,则可能会发生这种情况。或者您可能想调用此函数而不是返回它 在另一个项目,我有相同的功能,但不同的工作 我对行使用WebPack和reactstrap 我的班级 import React, { Component } from 'react'; import {Row, Col, Container} from 'reactstrap'; clas
函数作为子函数无效。如果返回组件而不是从渲染返回组件,则可能会发生这种情况。或者您可能想调用此函数而不是返回它
在另一个项目,我有相同的功能,但不同的工作
我对行使用WebPack和reactstrap
我的班级
import React, { Component } from 'react';
import {Row, Col, Container} from 'reactstrap';
class Test extends Component {
constructor(props) {
super(props);
this.insert = this.insert.bind(this);
}
insert() {
var list = [];
list.push(
<Row>
<Col>
<p>Test data</p>
</Col>
</Row>);
return {list};
}
render() {
return (
<div>
<Container>
{this.insert}
</Container>
</div>
);
}
}
export default Test;
import React,{Component}来自'React';
从“reactstrap”导入{Row,Col,Container};
类测试扩展了组件{
建造师(道具){
超级(道具);
this.insert=this.insert.bind(this);
}
插入(){
var列表=[];
list.push(
测试数据
);
返回{list};
}
render(){
返回(
{this.insert}
);
}
}
导出默认测试;
您可以试试这个
import React, { Component } from "react";
import { Row, Col, Container } from "reactstrap";
class MyComponent extends Component {
insert() {
var list = [];
list.push(
<Row>
<Col>
<p>Test data</p>
</Col>
</Row>
);
return list;
}
render() {
return (
<div>
<Container>{this.insert()}</Container>
</div>
);
}
}
export default MyComponent;
import React,{Component}来自“React”;
从“reactstrap”导入{Row,Col,Container};
类MyComponent扩展组件{
插入(){
var列表=[];
list.push(
测试数据
);
退货清单;
}
render(){
返回(
{this.insert()}
);
}
}
导出默认MyComponent;