我正在使用'react-table'组件https://react-table.js.org
我想为一列添加点击事件(稍后我会打开一个显示基于此事件的信息的模态).
如何在 React Table 中使用单选输入而不是复选框作为可选表?
有一个复选框但不是单选按钮的示例:https://github.com/tannerlinsley/react-table/blob/master/examples/row-selection/src/App.js
更改 InminatedCheckox 以使用无线电输入不起作用,因为反应表中的选择状态未更新:
const IndeterminateCheckbox = React.forwardRef(({ indeterminate, ...rest }, ref) => {
const defaultRef = React.useRef();
const resolvedRef = ref || defaultRef;
useEffect(() => {
resolvedRef.current.indeterminate = indeterminate;
}, [resolvedRef, indeterminate]);
return <input name="select-radio" type="radio" ref={resolvedRef} {...rest} />
);
});
Run Code Online (Sandbox Code Playgroud)