The STJS bridge to Facebook's React JS gives you access to this great library using a Java syntax.
Supports ES6 React Classes
@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"));
- Add the maven dependency to your project.
<dependency>
<groupId>org.st-js.bridge</groupId>
<artifactId>react</artifactId>
<version>0.16.7.bv0</version>
</dependency>
- Enjoy, you're good to go.
ReactClass
doesn't exist anymore, Please useextends React.Component
. You can follow any guide that helps convert fromReact.createClass
to ES6 Classes, for example : https://daveceddia.com/convert-createclass-to-es6-class/React.PropTypes
is now justPropTypes
update your dependencies