public class React extends Rollup
Write React applications easily in the JVM.
Download react.js and
react-dom.js into
public/js/lib folder.
Then add the react processor to conf/assets.conf:
assets {
fileset {
index: index.js
}
pipeline {
dev: [react]
dist: [react]
}
}
Write some react code public/js/index.js:
import React from 'react';
import ReactDOM from 'react-dom';
const Hello = () => (
<p>Hello React</p>
)
ReactDOM.render(<Hello />, document.getElementById('root'));
Choose one of the available
template engines add the
index.js to the page:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>React App</title>
</head>
<body>
<div id="root"></div>
{{ index_scripts | raw}}
</body>
</html>
The {{ index_scripts | raw}} here is pebble
expression. Open an browser and try it.
This module give you a ready to use react environment with: ES6 and JSX
support via babel.js and
rollup.js.
You don't need to install anything node.js, npm, ... nothing,
babel.js and
rollup.js run on top of
j2v8 as part of the JVM process.
Just drop the
react-router-dom.js
into the public/js/lib folder and use it.
It supports all the option of rollup.js processor.
| Constructor and Description |
|---|
React() |
| Modifier and Type | Method and Description |
|---|---|
Map<String,Object> |
options() |
name, set, set, toStringexcludes, getCopyright © 2017. All rights reserved.