Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
t-hiroyoshi committed Nov 21, 2015
1 parent 31c207c commit 5c1f14f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
43 changes: 22 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@ npm install react-dnd-item --save

```js
import React, { Component } from 'react';
import { DragDropContext }from "react-dnd";
import HTML5Backend from "react-dnd-html5-backend";
import { DnDItem, DropPositions } from "react-dnd-item";
import { DragDropContext }from 'react-dnd';
import HTML5Backend from 'react-dnd-html5-backend';
import { DnDItem, DropPositions } from 'react-dnd-item';

@DragDropContext(HTML5Backend)
export default class YourComponent extends Component {
export default class ExampleDnD extends Component {
constructor(props) {
super(props);
this.state = {
somethings = [
{id: "1", name: "somethigs1"},
{id: "2", name: "somethigs2"},
{id: "3", name: "somethigs3"},
{id: "4", name: "somethigs4"},
{id: "5", name: "somethigs5"},
{id: "6", name: "somethigs6"}
somethings: [
{id: '1', name: 'somethigs1'},
{id: '2', name: 'somethigs2'},
{id: '3', name: 'somethigs3'},
{id: '4', name: 'somethigs4'},
{id: '5', name: 'somethigs5'},
{id: '6', name: 'somethigs6'}
]
};
}
Expand All @@ -65,24 +65,25 @@ export default class YourComponent extends Component {

switch (position) {
case TOP_LEFT:
// some actions
// return some action
case TOP_CENTER:
// some actions
// return some action
case TOP_RIGHT:
// some actions
// return some action
case MIDDLE_LEFT:
// some actions
// return some action
case MIDDLE_CENTER:
// some actions
// return some action
case MIDDLE_RIGHT:
// some actions
// return some action
case BOTTOM_LEFT:
// some actions
// return some action
case BOTTOM_CENTER:
// some actions
// return some action
case BOTTOM_RIGHT:
// some actions
// return some action
default:
return false;
}
}

Expand All @@ -100,7 +101,7 @@ export default class YourComponent extends Component {
<div>
{somethings.map(something =>
<DnDItem dropAction={dropAction} id={something.id} key={something.id}>
<div>{item.name}</div>
<div>{something.name}</div>
</DnDItem>
)}
</div>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-dnd-item",
"version": "0.1.0",
"version": "0.1.1",
"description": "A draggable and droppable item comopnent for React",
"main": "lib/index.js",
"scripts": {
Expand Down

0 comments on commit 5c1f14f

Please sign in to comment.