我遇到了 ContainerComponent 和 ContainerProps 的问题,我认为问题在于“li”是字符串类型,我需要明确地将其定义为
React.ElementType
<ListItem
ContainerComponent="li"
ContainerProps={{ ref: provided.innerRef }}
{...provided.draggableProps}
{...provided.dragHandleProps}
style={getItemStyle(
snapshot.isDragging,
provided.draggableProps.style
)}
>
我遇到的错误:
没有与此调用匹配的过载。
最后一次重载给出了以下错误。
类型 '"li"' 不能分配给类型 'ElementType
答案 0 :(得分:0)
通过写作解决了这个问题:
<ListItem
ContainerComponent={(<li />).type}
ref={provided.innerRef}
{...provided.draggableProps}
{...provided.dragHandleProps}
style={getItemStyle
snapshot.isDragging,
provided.draggableProps.style)}