我在其中包含项目的列。目前,根据我从react-beautiful-dnd
复制的代码,这些列和项目都是可拖动的,并且运行良好,但是我不希望这些列是可拖动的。
如果我删除了<Draggable/>
组件,React
会对使用函数作为子项感到沮丧。我尝试了许多其他事情,但没有任何运气。关于如何从此组件中删除列拖动功能的任何建议?
// @flow
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'react-emotion';
import { Draggable } from 'react-beautiful-dnd';
import { grid, colors, borderRadius } from './dnd/constants';
import PlayerList from './dnd/player-list';
import Title from './dnd/title';
const Container = styled('div')`
margin: ${grid}px;
`;
const Header = styled('div')`
display: flex;
align-items: center;
justify-content: center;
border-top-left-radius: ${borderRadius}px;
border-top-right-radius: ${borderRadius}px;
background-color: ${({ isDragging }) => (isDragging ? colors.blue.lighter : colors.blue.light)};
transition: background-color 0.1s ease;
&:hover {
background-color: ${colors.blue.lighter};
}
`;
const Column = ({ title, players, index }) => (
<Draggable draggableId={title} index={index}>
{(provided, snapshot) => (
<Container innerRef={provided.innerRef} {...provided.draggableProps}>
<Header isDragging={snapshot.isDragging}>
<Title
isDragging={snapshot.isDragging}
{...provided.dragHandleProps}
>
{title}
</Title>
</Header>
<PlayerList
listId={title}
players={players}
/>
</Container>
)}
</Draggable>
);
Column.propTypes = {
title: PropTypes.string.isRequired,
players: PropTypes.arrayOf(PropTypes.shape({})).isRequired,
index: PropTypes.number.isRequired,
};
export default Column;
答案 0 :(得分:1)
// good cards
const ammoCards = [...Array(4)].map(i => new Card('ammunition', null, 1, null));
const beerCards = [...Array(4)].map(i => new Card('beer', null, 1, null));
// all other good cards
...
const goodCards = [...ammoCards, ...beerCards];
// repeat for bad cards
// and then
const allCards = [...goodCards, ...badCards];
完全删除Draggable
Column
const Column = ({ title, players, index }) => (
<Container>
<Header isDragging={false}>
<Title isDragging={false}>
{title}
</Title>
</Header>
<PlayerList
listId={title}
players={players}
/>
</Container>
);
的{{1}}包装。这很可能在Droppable
组件中,您没有在其中包含