Skip to content

Commit

Permalink
Added one more post — just reusing test from docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dborisenko committed Jan 31, 2019
1 parent 493c980 commit e713c61
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions _posts/2019-01-31-building-sortable-lists-with-scalajs-react.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
layout: post
title: Building Sortable lists with scalajs-react
tags: [react-sortable-hoc, react, scalajs]
bigimg: /img/???.jpg
gh-repo: dborisenko/scalajs-react-components
gh-badge: [star, fork, follow]
---

# React Sortable (HOC)

React Sortable (HOC) is a set of higher-order components to turn any list into an animated, touch-friendly, sortable list. It is possible to use it with Scala. Here I will provide short instructions how to do that.

## Dependencies

The code is based one the [react-sortable-hoc](https://github.com/dborisenko/scalajs-react-components#react-sortable-hoc) for [React Sortable (HOC)](https://github.com/clauderic/react-sortable-hoc) component. It is written using [scalajs-react](https://github.com/japgolly/scalajs-react) library for ScalaJs.

Add dependencies in `build.sbt`:

```scala
libraryDependencies ++= Seq(
"com.dbrsn.scalajs.react.components" %%% "react-sortable-hoc" % "0.3.1"
)
npmDependencies in Compile ++= Seq(
"react-sortable-hoc" -> "1.4.0",
"react" -> "16.7.0",
"react-dom" -> "16.7.0"
)
```

## Usage

Example of usage:

```scala
case class Model(text: String)
case class Props(model: Model)

val item1 = "Test 1"
val item2 = "Test 2"

SortableList[Model, Props].Props(
listToDisplay = List(Model(item1), Model(item2)),
sortableContainerProps = SortableContainer.Props(),
externalProps = Props,
itemComponent = raw
).render
```

## Source Code

Source code can be found [here](https://github.com/dborisenko/scalajs-react-components)

0 comments on commit e713c61

Please sign in to comment.