Seamlessly bringing Parse data into your React applications.
NOTE: Parse + React only supports the Parse JS SDK up to version 1.6.14. Behavior with 1.7.* is unpredictable, and 1.8.* breaks functionality with the new LiveQueries feature. As developers, we want to encourage patterns that integrate easily into both the server and the client, and are working on a new low-level SDK that works well with Redux and React Native. When that codebase is ready for production apps, we will publish a new recommended starter kit for apps built on Parse & React.
Parse + React is an interface layer on top of the Parse JS SDK that provides simple access to the Parse API from React. It lets React components subscribe to Parse queries, and allows data mutations to be dispatched in a Flux-style manner. In the background, these subscriptions are managed in a way that lets these components automatically update as objects are created and modified, allowing user interfaces to be snappy and responsive.
To add Parse data to a component, it simply needs to subscribe to a standard
Parse Query. This is done through an implementation of the newly-proposed
observe() API for React. The
ParseReact Mixin allows a version of this new lifecycle method to be used today
with Parse Queries.
If you're using React with ES6 classes, we also provide a subclass of
React.Component that allows you to use the
observe() and Query-specific APIs.
var CommentBlock = React;
Whenever this component mounts, it will issue the query and the results will be
this.data.comments. Each time the query is re-issued, or objects
are modified locally that match the query, it will update itself to reflect
Mutations are dispatched in the manner of Flux Actions, allowing updates to be synchronized between many different components without requiring views to talk to each other. All of the standard Parse data mutations are supported, and you can read more about them in the Data Mutation guide.
// Create a new Comment object with some initial dataParseReactMutation;
If you're not familiar with React, we recommend you first walk through their tutorials before adding Parse data to your React applications.
Parse + React adds new functionality when React and the Parse JS SDK are used together, and it requires that those libraries be in place before it is initialized. The easiest way to do this is to load them on your page before loading the Parse + React library:
<!-- Now include parse-react.js -->...
If you're using a tool like Webpack or Browserify to enable Common JS
statements, you need to make sure you also include the
'parse' npm package
in your dependencies.
var React = ;var Parse = ;var ParseReact = ;// ...
As of version 1.6, the Parse JS SDK has a different build for React Native.
If you're using Parse+React on React Native, you'll need to require the
'parse-react/react-native' package instead.
// For React Native appsvar React = ;var Parse = ;var ParseReact = ;
See the CONTRIBUTING file for information on how to help out.
Copyright (c) 2015, Parse, LLC. All rights reserved.
You are hereby granted a non-exclusive, worldwide, royalty-free license to use, copy, modify, and distribute this software in source code or binary form for use in connection with the web services and APIs provided by Parse.
As with any software that integrates with the Parse platform, your use of this software is subject to the Parse Terms of Service [https://www.parse.com/about/terms]. This copyright notice shall be included in all copies or substantial portions of the software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.