This tutorial will show how to write a ''Hello Server'' application using ''React'' and ''Vaandroid''
Writing the application in React allows:
Client-Side Benefits
Server Side Benefits
This template pulls down the required libraries from CDN, and renders a component in a target div. Our source code is written in JSX and is rendered on-the-fly in the client browser.
<!DOCTYPE html>
<html lang="en">
</html>
class Form extends React.Component {
constructor() {
super();
this.state = {
name: ''
};
}
render() {
return <div>Please enter your name and press <em>Submit</em>.<br />
<input placeholder="Enter your name here" on<x>change={e=>this.handleName(e)}
value={this.state.name}/>
<button on<x>click={e=>this.handleSubmit()}>Submit</button>
</div>
}
handleName(e) {
this.setState({name: e.target.value});
}
handleSubmit() {
al<x>ert('Hello ' + this.state.name);
}
}
Send the code to the server by calling vaandroid.send(...)
handleSubmit() {
vaandroid.send('Hello ' + this.state.name);
}
Subscribe to the server's response by overriding vaandroid.receive(...)
constructor() {
super();
this.state = {
name: '',
caption: ''
};
vaandroid.receive = function (message) {
this.setState({caption: message});
}.bind(this);
}