Skip to content

Commit

Permalink
Add first version of React starter app
Browse files Browse the repository at this point in the history
  • Loading branch information
Sashko Stubailo committed Sep 14, 2015
1 parent cf1cf7a commit 4704aaa
Show file tree
Hide file tree
Showing 9 changed files with 187 additions and 0 deletions.
11 changes: 11 additions & 0 deletions examples/react-starter/.meteor/.finished-upgraders
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file contains information which helps Meteor properly upgrade your
# app when you run 'meteor update'. You should check it into version control
# with your project.

notices-for-0.9.0
notices-for-0.9.1
0.9.4-platform-file
notices-for-facebook-graph-api-2
1.2.0-standard-minifiers-package
1.2.0-meteor-platform-split
1.2.0-cordova-changes
1 change: 1 addition & 0 deletions examples/react-starter/.meteor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
local
22 changes: 22 additions & 0 deletions examples/react-starter/.meteor/packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Meteor packages used by this project, one per line.
# Check this file (and the other files in this directory) into your repository.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.

meteor-base # Packages every Meteor app needs to have
mobile-experience # Packages for a great mobile UX
mongo # The database Meteor supports right now
session # Client-side reactive dictionary for your app
jquery # Helpful client-side library
tracker # Meteor's client-side reactive programming library

standard-minifiers # JS/CSS minifiers run for production mode
es5-shim # ECMAScript 5 compatibility for older browsers.
ecmascript # Enable ECMAScript2015+ syntax in app code

autopublish # Publish all data to the clients (for prototyping)
insecure # Allow all DB writes from clients (for prototyping)

static-html # Render static HTML content
react # Everything you need to use React with Meteor
2 changes: 2 additions & 0 deletions examples/react-starter/.meteor/platforms
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
server
browser
1 change: 1 addition & 0 deletions examples/react-starter/.meteor/release
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[email protected]
73 changes: 73 additions & 0 deletions examples/react-starter/.meteor/versions
11 changes: 11 additions & 0 deletions examples/react-starter/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<head>
<title>react-skel</title>
</head>

<body>
<h1>Welcome to Meteor and React!</h1>

<p><a href="https://www.meteor.com/tutorials/react">Try the tutorial!</a></p>

<div id="react-container"></div>
</body>
65 changes: 65 additions & 0 deletions examples/react-starter/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// A collection that is synchronized across client and server with the
// 'autopublish' package. To control where the data is accessible from, remove
// 'autopublish' and use Meteor.publish and Meteor.subscribe
Items = new Mongo.Collection("items");

// A React component, defined in the normal way
App = React.createClass({
mixins: [ReactMeteorData],

// Load data from collections inside this special method enabled by the
// ReactMeteorData mixin. The results are attached to this.data on the
// component
getMeteorData() {
return {
items: Items.find().fetch()
};
},

addItem() {
const nextIndex = Items.find().count() + 1;

// We can insert from the client because we have the 'insecure' package
// installed. Remove it and use Meteor methods for better security
Items.insert({
text: "Hello world! " + nextIndex
});
},

renderItems() {
return this.data.items.map((item) => {
return (
<li key={item._id}>
{item.text}
</li>
);
});
},

render() {
return (
<div>
<ul>
{this.renderItems()}
</ul>

<button onClick={this.addItem}>
Add item
</button>
</div>
)
}
});

if (Meteor.isClient) {
// Code here runs on the client only

Meteor.startup(() => {
// Make sure to render after startup so the DOM is ready
React.render(<App />, document.getElementById("react-container"));
});
}

if (Meteor.isServer) {
// Code inside here will run on the server only
}
1 change: 1 addition & 0 deletions examples/react-starter/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* CSS declarations go here */

0 comments on commit 4704aaa

Please sign in to comment.