这是我第一次创建反应应用程序。
我想将按钮从 index.js 传递到使用 hooks 的表组件。
Declaration:
const testButton = () => {
return (
<React.Fragment>
<button>Test1</button>
<button>Test2</button>
<button>Test3</button>
<button>Test4</button>
<button>Test5</button>
</React.Fragment>
);
};
传递给 Table 组件
return (
<React.Fragment>
<TestTable
{...{
testButton}} />
</React.Fragment>
然后,表格组件将使用它来呈现包含按钮的表格。
export default function TestTable({
testButton,
...props
})
return (
{testButton});
我做得对吗?
我如何从 index.js 中导出它,在 Table component.js 中导入,并在 Table 组件中呈现?
谢谢你。
原文由 Dan 发布,翻译遵循 CC BY-SA 4.0 许可协议
我想你想要的是:
接着:
希望能帮助到你!