Skip to content

Instantly share code, notes, and snippets.

@brunoskonrad
Last active September 3, 2015 17:33
Show Gist options
  • Save brunoskonrad/1e8880751011c30d187b to your computer and use it in GitHub Desktop.
Save brunoskonrad/1e8880751011c30d187b to your computer and use it in GitHub Desktop.
var React = require('react');
var Parse = require('parse').Parse;
var ParseReact = require('parse-react');
// Inicia o Parse com as credenciais da tua app
Parse.initialize('foo', 'bar');
var App = React.createClass({
mixins: [ParseReact.Mixin],
observe: function() {
return {
// Consulta os dados na nuvem e pá
tests: (new Parse.Query('TestObject')).ascending('createdAt')
};
},
componentDidMount: function() {
// Cria um novo registro
ParseReact.Mutation.Create('TestObject', {foo: 'bar'}).dispatch();
},
render() {
return (
<div>
<h1>{this.props.title || 'Hello World'}</h1>
// Acessa os dados do parse no `this.data`
<p>{this.data.tests.length}</p>
</div>
);
}
});
React.render(<App title="Foobar"/>,
document.querySelector('[data-app]'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment