Skip to content

Instantly share code, notes, and snippets.

@dittos dittos/
Last active Dec 6, 2015

What would you like to do?
Possibility of React + GWT?
import static react.ReactDOM.*;
class TodoList extends ReactComponent {
public static final ReactProp<List<TodoItem>> ITEMS = ReactProp.create();
public static ReactElement.Builder<TodoList> builder() {
return ReactElement.builder(TodoList.class);
public ReactElement render() {
ReactElement.Builder builder = ul();
for (TodoItem item : get(ITEMS)) {
class TodoApp extends ReactComponent {
public static ReactElement.Builder<TodoApp> builder() {
return ReactElement.builder(TodoApp.class);
private static final ReactState<List<TodoItem>> ITEMS = ReactState.create();
private static final ReactState<String> TEXT = ReactState.create();
private final EventListener onChange = (e) -> {
private final EventListener handleSubmit = (e) -> {
List<TodoItem> nextItems = Lists.newArrayList(get(ITEMS));
nextItems.add(new TodoItem(System.currentTimeMillis(), get(TEXT)));
public ReactElement render() {
return div()
.prop(TodoList.ITEMS, get(ITEMS))
.prop("onSubmit", handleSubmit)
.prop("onChange", onChange)
.prop("value", get(TEXT))
.add("Add #" + (get(ITEMS).size() + 1))
ReactDOM.render(TodoApp.builder().build(), DOM.getElementById("container"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.