Skip to content

Commit

Permalink
Version 0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tonsky committed Apr 13, 2016
1 parent 1e28c18 commit 7fc5bf9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
28 changes: 28 additions & 0 deletions README.md
Expand Up @@ -119,6 +119,30 @@ or call `request-render` function:

`request-render` does not execute rendering immediately, instead, it will place your component to render queue and re-render on `requestAnimationFrame` callback. `request-render` is preferable way to refresh component.

## Server-side rendering

Since 0.7.0, Rum supports server-side rendering. In your clj/cljc file:

1. Import `rum.core` as usual
2. Define components using `rum/defc` or other macros as usual
3. Instead of mounting, call `rum/render-html` to render into a string
4. Generate HTML page using that string
5. On a client, mount _the same_ component over the node where you rendered your server-side component

```clojure
(require '[rum.core :as rum])

(rum/defc my-comp [s]
[:div s])

(rum/render-html (my-comp "hello"))
;; => "<div data-reactid=\".ibf34u\" data-react-checksum=\"189533501\">hello</div>"
```

Server-side components do not have full lifecycle support, but `:init`, `:will-mount` and `:did-mount` from mixins would be called at the component construction time.

For example, see [examples_page.clj](examples/rum/examples_page.clj).

## Mixins

Rum comes with a couple of mixins which emulate behaviors known from `quiescent`, `om` and `reagent`. Developing your own mixin is also very simple.
Expand Down Expand Up @@ -329,6 +353,10 @@ This is a detailed breakdown of what happens inside of Rum. By using `rum/defc`,

## Changes

### 0.7.0

- Server-side rendering via `rum/render-html` (thx [Alexander Solovyov](https://github.com/piranha))

### 0.6.0

- [ BREAKING ] Updated to [React 0.14.3](https://facebook.github.io/react/blog/2015/10/07/react-v0.14.html) (thx [Andrey Antukh](https://github.com/niwinz), PR #53)
Expand Down
4 changes: 2 additions & 2 deletions project.clj
@@ -1,4 +1,4 @@
(defproject rum "0.6.0"
(defproject rum "0.7.0"
:description "ClojureScript wrapper for React"
:license { :name "Eclipse"
:url "http://www.eclipse.org/legal/epl-v10.html" }
Expand All @@ -9,7 +9,7 @@
[org.clojure/clojurescript "1.7.228" :scope "provided"]
[cljsjs/react "0.14.3-0"]
[cljsjs/react-dom "0.14.3-1"]
[sablono "0.6.2"]]
[sablono "0.6.3"]]

:global-vars
{ *warn-on-reflection* true }
Expand Down
10 changes: 5 additions & 5 deletions target/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7fc5bf9

Please sign in to comment.