【发布时间】:2019-05-18 00:11:18
【问题描述】:
我希望将部分记录包含在 BooleanField(和 BooleanInput)的标签中。我正在尝试使用 WithProps 来完成此任务。
如果我使用
<BooleanField source="FileSystem" label="FileSystem" />
这似乎工作得很好。相反,如果我尝试包装它
const makeLabel = (props)=>{
let label = `Filesystem for ${props.record.id}`;
return {label};
}
const withLabel = withProps(makeLabel);
const BooleanFieldWithLabel = compose(withLabel)((props)=>{
console.log("props after compose",props);
return <BooleanField {...props}/>
});
然后使用<BooleanFieldWithLabel source="FileSystem" />它不会渲染任何标签。我尝试了几种不同的方法,但似乎没有任何效果,即使我可以在 console.log 中看到正确的标签在道具中。我在这里做错了什么?
【问题讨论】:
标签: reactjs react-admin recompose