有没有人能够使用带有 useDrag 和 useDrop 钩子的功能组件从https://github.com/react-dnd/react-dnd测试拖放功能?
根据此处找到的示例http://react-dnd.github.io/react-dnd/docs/testing,他们使用 DragSource 或 DropTarget HOC 装饰原始组件。例如:
// ...
export interface BoxProps {
name: string
// Collected Props
isDragging: boolean
connectDragSource: ConnectDragSource
}
const Box: React.FC<BoxProps> = ({ name, isDragging, connectDragSource }) => {
const opacity = isDragging ? 0.4 : 1
return (
<div ref={connectDragSource} style={{ ...style, opacity }}>
{name}
</div>
)
}
export default DragSource(
ItemTypes.BOX,
{
beginDrag: (props: BoxProps) => ({ name: props.name }),
endDrag(props: BoxProps, monitor: DragSourceMonitor) { …Run Code Online (Sandbox Code Playgroud) 在我的系统中,我有一些实体从概念上继承自User。例如,我可以有供应商和普通消费者。我希望扩展User实体,以便我可以继承所有用户利益,例如注册,登录,丢失密码等。
我有几个选择:
1.使用一种Hibernate继承策略(https://docs.jboss.org/hibernate/orm/3.5/reference/en/html/inheritance.html)扩展User实体,但是看起来需要对代码进行大量更改。我还必须确保表生成也正确并且可以在liquibase上正常工作。
2.将所有必要的属性添加到用户实体,然后添加供应商和消费者作为角色。我只是不习惯这样做,因为User表不会被规范化。
3.创建从每个实体到用户实体的关系,但是在这种情况下,我不清楚如何继承用户管理的好处。
有没有人做过类似的事情,以便对此有所了解?
提前致谢。