当前位置:   article > 正文

Tutorial

klgqqe

Tutorial

Now that you've read the overview, it's adventure time!

Adventure Time!

In this tutorial, we're going to build a Chess game with React and React DnD. I'm kidding! Writing a full-blown Chess game is totally out of scope of this tutorial. What we're going to build is a tiny app with a Chess board and a lonely Knight. The Knight will be draggable according to the Chess rules.

If you're comfortable with React already, feel free to skip ahead to the final section: Adding Drag-and-Drop Interaction

We will use this example to demonstrate the data-driven philosophy of react-dnd. You will learn how to create a drag source and a drop target, wire them together with your React components, and change their appearance in response to the drag and drop events.

Now let's build something!

Table of Contents

Setup

In this tutorial, the code examples are use function-components and modern JavaScript syntax. It's recommended to use a build-step to transpile these features into your target environment. We recommend using create-react-app.

The app we're going to build is available as an example on this website.

Building the Game

Identifying the Components

We're going to start by creating some React components first, with no thoughts of the drag and drop interaction. Which components is our Lonely Knight app going to be made of? I can think of a few:

  • Knight, our lonely knight piece;
  • Square, a single square on the board;
  • Board, the whole board with 64 squares.

Let's consider their props.

  • Knightprobably needs no props. It has a position, but there's no reason for the Knightto know it, because it can be positioned by being placed into a Squareas a child.
  • It is tempting to give Squareits position via props, but this, again, is not necessary, because the only information it really needs for the rendering is the color. I'm going to make Squarewhite by default, and add a blackboolean prop. And of course Squaremay accept a single child: the chess piece that is currently on it. I chose white as the default background color to match the browser defaults.
  • The Boardis tricky. It makes no sense to pass Squares as children to it, because what else could a board contain? Therefore it probably owns the Squares. But then, it also needs to own the Knightbecause this guy needs to be placed inside one of those Squares. This means that the Boardneeds to know the knight's current position. In a real Chess game, the Boardwould accept a data structure describing all the pieces, their colors and positions, but for us, a knightPositionprop will suffice. We will use two-item arrays as coordinates, with [0, 0]referring to the A8 square. Why A8 instead of A1? To match the browser coordinate orientation. I tried it another way and it just messed with my head too much.

Where will the current state live? I really don't want to put it into the Boardcomponent. It's a good idea to have as little state in your components as possible, and because the Boardwill already have some layout logic, I don't want to also burden it with managing the state.

The good news is, it doesn't matter at this point. We're just going to write the components as if the state existed somewhere, and make sure that they render correctly when they receive it via props, and think about managing the state afterwards!

Creating the Components

I prefer to start bottom-up, because this way I'm always working with something that already exists. If I were to build the Boardfirst, I wouldn't see my results until I'm done with the Square. On the other hand, I can build and see the Squareright away without even thinking of the Board. I think that the immediate feedback loop is important (you can tell that by another project I work on).

In fact I'm going to start with the Knight. It doesn't have any props at all, and it's the easiest one to build:

  1. import React from 'react'
  2. export default function Knight() {
  3. return <span></span>
  4. }

Yes, ♘ is the Unicode knight! It's gorgeous. We could've made its color a prop, but in our example we're not going to have any black knights, so there is no need for that.

It seems to render fine, but just to be sure, I immediately changed my entry point to test it:

  1. import React from 'react'
  2. import ReactDOM from 'react-dom'
  3. import Knight from './Knight'
  4. ReactDOM.render(<Knight />, document.getElementById('root'))

Screenshot

I'm going to do this every time I work on another component, so that I always have something to render. In a larger app, I would use a component playground like cosmos so I'd never write the components in the dark.

I see my Knighton the screen! Time to go ahead and implement the Squarenow. Here is my first stab:

  1. import React from 'react'
  2. export default function Square({ black }) {
  3. const fill = black ? 'black' : 'white'
  4. return <div style={{ backgroundColor: fill }} />
  5. }

Now I change the entry point code to see how the Knightlooks inside a Square:

  1. import React from 'react'
  2. import ReactDOM from 'react-dom'
  3. import Knight from './Knight'
  4. import Square from './Square'
  5. ReactDOM.render(
  6. <Square black>
  7. <Knight />
  8. </Square>,
  9. document.getElementById('root'),
  10. )

Sadly, the screen is empty. I made a few mistakes:

  • I forgot to give Squareany dimensions so it just collapses. I don't want it to have any fixed size, so I'll give it width: '100%'and height: '100%'to fill the container.
  • I forgot to put {children}inside the divreturned by the Square, so it ignores the Knightpassed to it.

Even after correcting these two mistakes, I still can't see my Knightwhen the Squareis black. That's because the default page body text color is black, so it is not visible on the black Square. I could have fixed this by giving Knighta color prop, but a much simpler fix is to set a corresponding colorstyle in the same place where I set backgroundColor. This version of Squarecorrects the mistakes and works equally great with both colors:

  1. import React from 'react'
  2. export default function Square({ black, children }) {
  3. const fill = black ? 'black' : 'white'
  4. const stroke = black ? 'white' : 'black'
  5. return (
  6. <div
  7. style={{
  8. backgroundColor: fill,
  9. color: stroke,
  10. width: '100%',
  11. height: '100%',
  12. }}
  13. >
  14. {children}
  15. </div>
  16. )
  17. }

Screenshot

Finally, time to get started with the Board! I'm going to start with an extremely naïve version that just draws the same single square:

  1. import React from 'react'
  2. import Square from './Square'
  3. import Knight from './Knight'
  4. export default function Board() {
  5. return (
  6. <div>
  7. <Square black>
  8. <Knight />
  9. </Square>
  10. </div>
  11. )
  12. }

My only intention so far is to make it render, so that I can start tweaking it:

  1. import React from 'react'
  2. import ReactDOM from 'react-dom'
  3. import Board from './Board'
  4. ReactDOM.render(
  5. <Board knightPosition={[0, 0]} />,
  6. document.getElementById('root'),
  7. )

Indeed, I can see the same single square. I'm now going to add a whole bunch of them! But I don't know where to start. What do I put in render? Some kind of a forloop? A mapover some array?

To be honest, I don't want to think about it now. I already know how to render a single square with or without a knight. I also know the knight's position thanks to the knightPositionprop. This means I can write the renderSquaremethod and not worry about rendering the whole board just yet.

My first attempt at renderSquarelooks like this:

  1. function renderSquare(x, y, [knightX, knightY]) {
  2. const black = (x + y) % 2 === 1
  3. const isKnightHere = knightX === x && knightY === y
  4. const piece = isKnightHere ? <Knight /> : null
  5. return <Square black={black}>{piece}</Square>
  6. }

I can already give it a whirl by changing the Board's rendering to be

  1. export default function Board({ knightPosition }) {
  2. return (
  3. <div
  4. style={{
  5. width: '100%',
  6. height: '100%',
  7. }}
  8. >
  9. {renderSquare(0, 0, knightPosition)}
  10. {renderSquare(1, 0, knightPosition)}
  11. {renderSquare(2, 0, knightPosition)}
  12. </div>
  13. )
  14. }

Screenshot

At this point, I realize that I forgot to give my squares any layout. I'm going to use Flexbox. I added some styles to the root div, and also wrapped the Squares into divs so I could lay them out. Generally it's a good idea to keep components encapsulated and ignorant of how they're being laid out, even if this means adding wrapper divs.

  1. import React from 'react'
  2. import Square from './Square'
  3. import Knight from './Knight'
  4. function renderSquare(i, [knightX, knightY]) {
  5. const x = i % 8
  6. const y = Math.floor(i / 8)
  7. const isKnightHere = x === knightX && y === knightY
  8. const black = (x + y) % 2 === 1
  9. const piece = isKnightHere ? <Knight /> : null
  10. return (
  11. <div key={i} style={{ width: '12.5%', height: '12.5%' }}>
  12. <Square black={black}>{piece}</Square>
  13. </div>
  14. )
  15. }
  16. export default function Board({ knightPosition }) {
  17. const squares = []
  18. for (let i = 0; i < 64; i++) {
  19. squares.push(renderSquare(i, knightPosition))
  20. }
  21. return (
  22. <div
  23. style={{
  24. width: '100%',
  25. height: '100%',
  26. display: 'flex',
  27. flexWrap: 'wrap',
  28. }}
  29. >
  30. {squares}
  31. </div>
  32. )
  33. }

Screenshot

It looks pretty awesome! I don't know how to constrain the Boardto maintain a square aspect ratio, but this should be easy to add later.

Think about it for a moment. We just went from nothing to being able to move the Knighton a beautiful Boardby changing the knightPosition:

  1. import React from 'react'
  2. import ReactDOM from 'react-dom'
  3. import Board from './Board'
  4. ReactDOM.render(
  5. <Board knightPosition={[7, 4]} />,
  6. document.getElementById('root'),
  7. )

Screenshot

The declarativeness is fantastic! That's why people love working with React.

Adding Game State

We want to make the Knightdraggable. What we need in order to pull this off is to keep the current knightPositionin some kind of state storage, and have some way to change it.

Because setting up this state requires some thought, we won't try to implement dragging at the same time. Instead, we'll start with a simpler implementation. We will move the Knightwhen you click a particular Square, but only if this is allowed by the Chess rules. Implementing this logic should give us enough insight into managing the state, so we can replace clicking with the drag and drop once we've dealt with that.

React is not opinionated about the state management or the data flow; you can use Flux, Redux, Rx or even Backbone nah, avoid fat models and separate your reads from writes.

I don't want to bother with installing or setting up Redux for this simple example, so I'm going to follow a simpler pattern. It won't scale as well as Redux, but I also don't need it to. I have not decided on the API for my state manager yet, but I'm going to call it Game, and it will definitely need to have some way of signaling data changes to my React code.

Since I know this much, I can rewrite my index.jswith a hypothetical Gamethat doesn't exist yet. Note that this time, I'm writing my code in blind, not being able to run it yet. This is because I'm still figuring out the API:

  1. import React from 'react'
  2. import ReactDOM from 'react-dom'
  3. import Board from './Board'
  4. import { observe } from './Game'
  5. const root = document.getElementById('root')
  6. observe(knightPosition =>
  7. ReactDOM.render(<Board knightPosition={knightPosition} />, root),
  8. )

What is this observefunction I import? It's just the most minimal way I can think of to subscribe to a changing state. I could've made it an EventEmitterbut why on Earth even go there when all I need is a single change event? I could have made Gamean object model, but why do that, when all I need is a stream of values?

Just to verify that this subscription API makes some sense, I'm going to write a fake Gamethat emits random positions:

  1. export function observe(receive) {
  2. const randPos = () => Math.floor(Math.random() * 8)
  3. setInterval(() => receive([randPos(), randPos()]), 500)
  4. }

It feels so good to be back in the rendering game!

Screenshot

This is obviously not very useful. If we want some interactivity, we're going to need a way to modify the Gamestate from our components. For now, I'm going to keep it simple and expose a moveKnightfunction that directly modifies the internal state. This is not going to fare well in a moderately complex app where different state storages may be interested in updating their state in response to a single user action, but in our case this will suffice:

  1. let knightPosition = [0, 0]
  2. let observer = null
  3. function emitChange() {
  4. observer(knightPosition)
  5. }
  6. export function observe(o) {
  7. if (observer) {
  8. throw new Error('Multiple observers not implemented.')
  9. }
  10. observer = o
  11. emitChange()
  12. }
  13. export function moveKnight(toX, toY) {
  14. knightPosition = [toX, toY]
  15. emitChange()
  16. }

Now, let's go back to our components. Our goal at this point is to move the Knightto a Squarethat was clicked. One way to do that is to call moveKnightfrom the Squareitself. However, this would require us to pass the Squareits position. Here is a good rule of thumb:

If a component doesn't need some data for rendering, it doesn't need that data at all.

The Squaredoes not need to know its position to render. Therefore, it's best to avoid coupling it to the moveKnightmethod at this point. Instead, we are going to add an onClickhandler to the divthat wraps the Squareinside the Board:

  1. import React from 'react'
  2. import Square from './Square'
  3. import Knight from './Knight'
  4. import { moveKnight } from './Game'
  5. /* ... */
  6. function renderSquare(i, knightPosition) {
  7. /* ... */
  8. return <div onClick={() => handleSquareClick(x, y)}>{/* ... */}</div>
  9. }
  10. function handleSquareClick(toX, toY) {
  11. moveKnight(toX, toY)
  12. }

We could have also added an onClickprop to Squareand used it instead, but since we're going to remove the click handler in favor of the drag and drop interface later anyway, why bother.

The last missing piece right now is the Chess rule check. The Knightcan't just move to an arbitrary square, it is only allowed to make L-shaped moves. I'm adding a canMoveKnight(toX, toY)function to the Gameand changing the initial position to A2 to match the Chess rules:

  1. let knightPosition = [1, 7]
  2. /* ... */
  3. export function canMoveKnight(toX, toY) {
  4. const [x, y] = knightPosition
  5. const dx = toX - x
  6. const dy = toY - y
  7. return (
  8. (Math.abs(dx) === 2 && Math.abs(dy) === 1) ||
  9. (Math.abs(dx) === 1 && Math.abs(dy) === 2)
  10. )
  11. }

Finally, I'm adding a canMoveKnightcheck to the handleSquareClickmethod:

  1. import { canMoveKnight, moveKnight } from './Game'
  2. /* ... */
  3. function handleSquareClick(toX, toY) {
  4. if (canMoveKnight(toX, toY)) {
  5. moveKnight(toX, toY)
  6. }
  7. }

Screenshot

Working great so far!

Adding Drag and Drop Interaction

This is the part that actually prompted me to write this tutorial. We are now going to see how easy React DnD makes it to add some drag and drop interaction to your existing components.

This part assumes you are at least somewhat familiar with the concepts presented in the overview, such as the backends, the collecting functions, the types, the items, the drag sources, and the drop targets. If you didn't understand everything, it's fine, but make sure you at least give it a chance before jumping into the coding process.

We're going to start by installing React DnD and the HTML5 backend for it:

yarn add react-dnd react-dnd-html5-backend

In the future, you might want to explore alternative third-party backends, such as the touch backend, but this is out of scope of this tutorial.

Setting up the Drag and Drop Context

The first thing we need to set up in our app is the DndProvider. This should be mounted near the top of our application. We need this to specify that we're going to use the HTML5Backend.

  1. import React from 'react'
  2. import { DndProvider } from 'react-dnd'
  3. import Backend from 'react-dnd-html5-backend'
  4. function Board() {
  5. /* ... */
  6. return <DndProvider backend={Backend}>...</DndProvider>
  7. }

Define Drag Types

Next, I'm going to create the constants for the draggable item types. We're only going to have a single item type in our game, a KNIGHT. I'm creating a Constantsmodule that exports it:

  1. export const ItemTypes = {
  2. KNIGHT: 'knight',
  3. }

The preparation work is done now. Let's make the Knightdraggable!

Make the Knight Draggable

The useDraghook accepts a specification object. In this object, item.typeis set to the constant we just defined, so now we need to write a collecting function.

  1. const [{ isDragging }, drag] = useDrag({
  2. item: { type: ItemTypes.KNIGHT },
  3. collect: monitor => ({
  4. isDragging: !!monitor.isDragging(),
  5. }),
  6. })

Let's break this down:

  • useDragaccepts a specification object. The item.typeproperty is required, and specifies the type of item being dragged. We could also attach extra information here to identify the kind of piece being dragged, but since this is a toy application we only need to define the type.
  • collectdefines a collector function: this is basically a way to transform state from the drag-and-drop system into usable props for your components.
  • The result arraycontains
  • A propsobject as the first item - this contains the properties you collected from the drag-and-drop system.
  • A ref function as the second item. This is used to attach your DOM elements to react-dnd.

Let's take a look at the whole Knightcomponent now, including the useDragcall and the updated renderfunction:

  1. import React from 'react'
  2. import { ItemTypes } from './Constants'
  3. import { useDrag } from 'react-dnd'
  4. function Knight() {
  5. const [{isDragging}, drag] = useDrag({
  6. item: { type: ItemTypes.KNIGHT },
  7. collect: monitor => ({
  8. isDragging: !!monitor.isDragging(),
  9. }),
  10. })
  11. return (
  12. <div
  13. ref={drag}
  14. style={{
  15. opacity: isDragging ? 0.5 : 1,
  16. fontSize: 25,
  17. fontWeight: 'bold',
  18. cursor: 'move',
  19. }}
  20. >
  21. </div>,
  22. )
  23. }
  24. export default Knight

Screenshot

Make the Board Squares Droppable

The Knightis now a drag source, but there are no drop targets to handle the drop yet. We're going to make the Squarea drop target now.

This time, we can't avoid passing the position to the Square. After all, how can the Squareknow where to move the dragged knight if the Squaredoesn't know its own position? On the other hand, it still feels wrong because the Squareas an entity in our application has not changed, and if it used to be simple, why complicate it? When you face this dilemma, it's time to separate the smart and dumb components.

I'm going to introduce a new component called the BoardSquare. It renders the good old Square, but is also aware of its position. In fact, it's encapsulating some of the logic that the renderSquaremethod inside the Boardused to do. React components are often extracted from such render submethods when the time is right.

Here is the BoardSquareI extracted:

  1. import React from 'react'
  2. import Square from './Square'
  3. export default function BoardSquare({ x, y, children }) {
  4. const black = (x + y) % 2 === 1
  5. return <Square black={black}>{children}</Square>
  6. }

I also changed the Boardto use it:

  1. /* ... */
  2. import BoardSquare from './BoardSquare'
  3. function renderSquare(i, knightPosition) {
  4. const x = i % 8
  5. const y = Math.floor(i / 8)
  6. return (
  7. <div key={i} style={{ width: '12.5%', height: '12.5%' }}>
  8. <BoardSquare x={x} y={y}>
  9. {renderPiece(x, y, knightPosition)}
  10. </BoardSquare>
  11. </div>
  12. )
  13. }
  14. function renderPiece(x, y, [knightX, knightY]) {
  15. if (x === knightX && y === knightY) {
  16. return <Knight />
  17. }
  18. }

Let's now wrap the BoardSquarewith a useDrophook. I'm going to write a drop target specification that only handles the dropevent:

  1. const [, drop] = useDrop({
  2. accept: ItemTypes.KNIGHT,
  3. drop: () => moveKnight(x, y),
  4. })

See? The dropmethod has the propsof the BoardSquarein scope, so it knows where to move the knight when it drops. In a real app, I might also use monitor.getItem()to retrieve the dragged item that the drag source returned from beginDrag, but since we only have a single draggable thing in the whole application, I don't need it.

In my collecting function I'm going to ask the monitor whether the pointer is currently over the BoardSquareso I can highlight it:

  1. const [{ isOver, canDrop }, drop] = useDrop({
  2. accept: ItemTypes.KNIGHT,
  3. drop: () => moveKnight(x, y),
  4. collect: mon => ({
  5. isOver: !!mon.isOver(),
  6. canDrop: !!mon.canDrop(),
  7. }),
  8. })

After changing the renderfunction to connect the drop target and show the highlight overlay, here is what BoardSquarecame to be:

  1. import React from 'react'
  2. import Square from './Square'
  3. import { canMoveKnight, moveKnight } from './Game'
  4. import { ItemTypes } from './Constants'
  5. import { useDrop } from 'react-dnd'
  6. function BoardSquare({ x, y, children }) {
  7. const black = (x + y) % 2 === 1
  8. const [{ isOver }, drop] = useDrop({
  9. accept: ItemTypes.KNIGHT,
  10. drop: () => moveKnight(x, y),
  11. collect: monitor => ({
  12. isOver: !!monitor.isOver(),
  13. }),
  14. })
  15. return (
  16. <div
  17. ref={drop}
  18. style={{
  19. position: 'relative',
  20. width: '100%',
  21. height: '100%',
  22. }}
  23. >
  24. <Square black={black}>{children}</Square>
  25. {isOver && (
  26. <div
  27. style={{
  28. position: 'absolute',
  29. top: 0,
  30. left: 0,
  31. height: '100%',
  32. width: '100%',
  33. zIndex: 1,
  34. opacity: 0.5,
  35. backgroundColor: 'yellow',
  36. }}
  37. />
  38. )}
  39. </div>,
  40. )
  41. }
  42. export default BoardSquare

Screenshot

This is starting to look good! There is just one change left to complete this tutorial. We want to highlight the BoardSquares that represent the valid moves, and only process the drop if it happened over one of those valid BoardSquares.

Thankfully, it is really easy to do with React DnD. I just need to define a canDropmethod in my drop target specification:

  1. const [{ isOver, canDrop }, drop] = useDrop({
  2. accept: ItemTypes.KNIGHT,
  3. canDrop: () => canMoveKnight(x, y),
  4. drop: () => moveKnight(x, y),
  5. collect: monitor => ({
  6. isOver: !!monitor.isOver(),
  7. canDrop: !!monitor.canDrop(),
  8. }),
  9. })

I'm also adding monitor.canDrop()to my collecting function, as well as some overlay rendering code to the component:

  1. import React from 'react'
  2. import Square from './Square'
  3. import { canMoveKnight, moveKnight } from './Game'
  4. import { ItemTypes } from './Constants'
  5. import { useDrop } from 'react-dnd'
  6. function BoardSquare({ x, y, children }) {
  7. const black = (x + y) % 2 === 1
  8. const [{ isOver }, drop] = useDrop({
  9. accept: ItemTypes.KNIGHT,
  10. drop: () => moveKnight(x, y),
  11. canDrop: () => canMoveKnight(x, y),
  12. collect: monitor => ({
  13. isOver: !!monitor.isOver(),
  14. canDrop: !!monitor.canDrop(),
  15. }),
  16. })
  17. return (
  18. <div
  19. ref={drop}
  20. style={{
  21. position: 'relative',
  22. width: '100%',
  23. height: '100%',
  24. }}
  25. >
  26. <Square black={black}>{children}</Square>
  27. {isOver && !canDrop && <Overlay color="red" />}
  28. {!isOver && canDrop && <Overlay color="yellow" />}
  29. {isOver && canDrop && <Overlay color="green" />}
  30. </div>,
  31. )
  32. }
  33. export default BoardSquare

Screenshot

Add a Drag Preview Image

The last thing I want to demonstrate is drag preview customization. Sure, the browser will screenshot the DOM node, but what if we want to show a custom image?

We are lucky again, because it is easy to do with React DnD. We just need to use the preview ref provided by the useDraghook.

  1. const [{ isDragging }, drag, preview] = useDrag({
  2. item: { type: ItemTypes.KNIGHT },
  3. collect: monitor => ({
  4. isDragging: !!monitor.isDragging(),
  5. }),
  6. })

This lets us connect up a dragPreviewin rendermethod, just like we used for drag items. react-dndalso provides a utility component, DragPreviewImage, which presents an image as a drag preview using this ref.

  1. const knightImage = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KTMInWQAAOD1JREFUeAHtnQm8nHdZ75939pkzZ805OVtyktMkTZOmTZrupaWUlkJBBUSKKIJ6URBRP16vF71yBVHB+5ErcvWjotWiVJZ6QfbSUmhLpemSpkmaNHvOvi9zZt9n7vf3nx7oLXCygJBq3mTOzLz7++zP73n+/zE7v5ynwHkKnKfAeQqcp8B5CpynwHkKnKfAeQqcp8B5CpynwHkKnKfAeQqcp8DKFHj60Xsu/dB73/bJB+75+PUr7/nvuzXw73v6c//s9Xrdd89dH/zwZ/72Pe9Mzz1ul2zffh13PfCjunPfj+rC58J1YYb/83f84Zf3fvUj72xvarKBgSttTXf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icspomckmvlGUKEBVSqvYeSL7VyfXbnYxcRWsGCtEomaNmHadCqWPodC+vln6ilwRRpFvvw0ugsfru4wRh/pqU4ceB/fcexz644pxiSSo23VQqLSKy8o/qj6OqQJvCgTgmcGZF5abykGWJaQ5IbDFlmQsO5K+ISXNJw9lr3XGbou5NuziPNkHaJIVqUKCp/cXMC873BKEEyIq7MptvNfV7+4nyQNIVf+vHouOQsMATQDJNXY7BSlUgxGORZagu/WZh96JWNM/z/f7+ryeKCEqHlZfmz3p//WVddXq93fV9et/xZIvn8z1r3nFeZ+wj6ElN7bqtV58GGCHdduw2OUeEjUi0CYF3cwjOzTn5C62VK5GyX1+ldu7k/vDcop/1ETPmlxvHap0FY9wud7KYu+EZuA4aFZsSZTFPXFaOkQe4cEg7XRKcb0rm4Gf7rKo4hir5w6ormpEgNpJhduB115gsgNcDNcnH4S6XsyV8Kxgb/iXMQSjaW/wcaEsvGjOMXYgAAAABJRU5ErkJggg==';
  2. render() {
  3. return (
  4. <>
  5. <DragPreviewImage connect={preview} src={knightImage} />
  6. <div
  7. ref={drag}
  8. style={{
  9. ...knightStyle,
  10. opacity: isDragging ? 0.5 : 1,
  11. }}
  12. >
  13. </div>
  14. </>
  15. )
  16. }
  17. }

Concluding Words

This tutorial guided you through creating the React components, making design decisions about them and the application state, and finally adding the drag and drop interaction. The goal of this tutorial was to show you that React DnD fits great with the philosophy of React, and that you should think about the app architecture first before diving into implementing the complex interactions.

Happy dragging and dropping.

Screenshot

Now go and play with it!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/木道寻08/article/detail/869537
推荐阅读
相关标签
  

闽ICP备14008679号