【发布时间】:2019-07-30 16:51:16
【问题描述】:
我是 React.js 的新手,我想在按钮单击事件上调用我的组件。
我的要求是,当我单击“下一步”按钮时,我应该调用我的下一个组件。我尝试使用 onClick 事件并传递返回 .jsx 代码的函数。但它没有渲染。
任何人都可以帮助我吗?
import React, { Component } from "react";
import { Button } from "antd";
class GoNext extends Component {
render() {
const nextCategory = () => {
return <Category2 />;
};
const renderNext = () => {
return (
<div>
<Button type="primary" onClick={nextCategory}>
Next Category
</Button>
</div>
);
};
return (
<div>
<h4>Successfully Submit!!!</h4>
{renderNext}
</div>
);
}
}
export default GoNext;
【问题讨论】:
-
这里没有导入 Category2 组件。
-
我建议你通过路由来实现。
标签: reactjs