我有这样的jsx,
import TableCell from '@mui/material/TableCell';
import TableCell from '@mui/material/TableRow';
<TableRow>
<TableCell sx={{minWidth:45,width:45,maxWidth:45,backgroundColor:"white"}}></TableCell>
</TableRow>
<TableRow>
来自材料ui
现在我想像这样增强TableRow,
const EnhancedTableRow= forwardRef((props,ref) => {
const myDivRef = useRef();
useImperativeHandle(ref,()=>({
setReload: () =>{
setReload(!reload);
},
getBoundingClientRect: ()=>{
return myDivRef.current.getBoundingClientRect();
},
isInDiv:(x,y) =>{
var pos = myDivRef.current.getBoundingClientRect();
if (x >= pos.x && y >= pos.y &&
x <= pos.x + pos.width &&
y <= pos.y + pos.height){
return true;
}
return false;
}
}));
return (<div ref={myDivRef}>
<TableRow sx={props.sx}>
????
</TableRow>
</div>)
});
所以,当我使用
EnhancedTableRow
而不是 TableRow
时
如何继承标签之间的值,例如
<TableCell sx={{minWidth:45,width:45,maxWidth:45,backgroundColor:"white"}}></TableCell>
到
EnhancedTableRow
组件?
我想把这个值放在
????
中 EnhancedTableRow
转发所有道具。
<TableRow {...props} />