Skip to content
React Bridge for st-js
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
README.md
pom.xml

README.md

Strongly-Typed Javascript (STJS) Bridge to Facebook's react JS

The STJS bridge to Facebook's React JS gives you access to this great library using a Java syntax.

Supports ES6 React Classes

extends React.Component style

@SyntheticType
@STJSBridge
public class HelloMessageProps extends Props{
    public String name;
}

public class HelloMessage extends Component<HelloMessageProps, State> {

    public String displayName = "HelloMessage";

    public static Map<String, TypeChecker> propTypes = $map("name", PropTypes.string.isRequired);

    @Override
    public ReactElement<?> render() {
        return React.createElement("div", null, "Hello ", this.props.name);
    }
}

React.render(React.createElement(HelloMessage, new HelloMessageProps() {{ name = "John"; }}), document.getElementById("reactContainer"));

Install

  1. Add the maven dependency to your project.
<dependency>
    <groupId>org.st-js.bridge</groupId>
    <artifactId>react</artifactId>
    <version>0.16.7.bv0</version>
</dependency>
  1. Enjoy, you're good to go.

Migrating from React 0.14 to React 16

  • ReactClass doesn't exist anymore, Please use extends React.Component. You can follow any guide that helps convert from React.createClass to ES6 Classes, for example : https://daveceddia.com/convert-createclass-to-es6-class/
  • React.PropTypes is now just PropTypes update your dependencies
You can’t perform that action at this time.