1 | # React Resolver ![https://img.shields.io/npm/v/react-resolver.svg](https://img.shields.io/npm/v/react-resolver.svg?style=flat-square) [![](https://img.shields.io/github/issues-raw/ericclemmons/react-resolver.svg?style=flat-square)](https://github.com/ericclemmons/react-resolver/issues) [![](https://img.shields.io/travis/ericclemmons/react-resolver/master.svg?style=flat-square)](https://travis-ci.org/ericclemmons/react-resolver) [![](https://img.shields.io/david/ericclemmons/react-resolver.svg?style=flat-square)](https://david-dm.org/ericclemmons/react-resolver#info=dependencies)
|
2 |
|
3 | > Async-rendering & data-fetching for universal React applications.
|
4 |
|
5 | React Resolver lets you **define data requirements _per-component_**
|
6 | and will **handle the nested, async rendering on both the server & client for you.**
|
7 |
|
8 | For example, the following will load & provide `this.props.user` for the
|
9 | `UserProfile` component:
|
10 |
|
11 | ```js
|
12 | import { resolve } from "react-resolver";
|
13 |
|
14 | @resolve("user", function(props) {
|
15 | return http.get(`/api/users/${props.params.userId}`);
|
16 | })
|
17 | class UserProfile extends React.Component {
|
18 | render() {
|
19 | const { user } = this.props;
|
20 | ...
|
21 | }
|
22 | }
|
23 | ```
|
24 |
|
25 | This is the equivalent to asynchronously loading `user` and providing it to
|
26 | the component as if it were provided directly:
|
27 |
|
28 | ```xml
|
29 | <UserProfile user={user} />
|
30 | ```
|
31 |
|
32 | This makes components _pure_, _stateless_, and _easy to test_ as a result.
|
33 |
|
34 | [![](https://img.shields.io/badge/slack-@react--resolver-61DAFB.svg?style=flat-square)](http://www.reactiflux.com)
|
35 | [![](https://img.shields.io/badge/GITTER-join%20chat-green.svg?style=flat-square)](https://gitter.im/ericclemmons/react-resolver?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
36 |
|
37 | - - -
|
38 |
|
39 | ### Installation
|
40 |
|
41 | _For environments that don't have native `Promise` support,
|
42 | install [ES6 Promise](https://github.com/jakearchibald/es6-promise)._
|
43 |
|
44 | ```shell
|
45 | $ npm install --save react-resolver
|
46 | ```
|
47 |
|
48 | _For React v0.13 support, install [v2.x.x](https://github.com/ericclemmons/react-resolver/tree/v2.0.5)._
|
49 |
|
50 | ```shell
|
51 | $ npm install --save react-resolver@2
|
52 | ```
|
53 |
|
54 |
|
55 | ## Documentation
|
56 |
|
57 | Complete documentation can be found here:
|
58 | > <http://ericclemmons.github.io/react-resolver/>
|
59 |
|
60 | - [Introduction](/docs/introduction)
|
61 | - [Getting Started](/docs/getting-started)
|
62 |
|
63 | - - -
|
64 |
|
65 | ## Development
|
66 |
|
67 | If you'd like to contribute to this project, all you need to do is clone
|
68 | this project and run:
|
69 |
|
70 | ```shell
|
71 | $ npm install
|
72 | $ npm test
|
73 | ```
|
74 |
|
75 |
|
76 | ## [Contributors](https://github.com/ericclemmons/react-resolver/graphs/contributors)
|
77 |
|
78 | - [Eric Clemmons](mailto:eric@smarterspam.com>) ([@ericclemmons][twitter])
|
79 | - [Kier Borromeo](https://github.com/srph)
|
80 | - [Dustan Kasten](https://github.com/iamdustan)
|
81 | - [Adrian Philipp](https://github.com/adri)
|
82 | - [Daniel Lo Nigro](https://github.com/Daniel15)
|
83 | - [Daniel Chao](https://github.com/bioball)
|
84 | - [Frederick Fogerty](https://github.com/frederickfogerty)
|
85 | - [Josh Perez](https://github.com/goatslacker)
|
86 |
|
87 |
|
88 | ## [License][license]
|
89 |
|
90 | > Internet Systems Consortium license
|
91 | > ===================================
|
92 | >
|
93 | > Copyright (c) 2015 Eric Clemmons
|
94 | >
|
95 | > Permission to use, copy, modify, and/or distribute this software for any purpose
|
96 | > with or without fee is hereby granted, provided that the above copyright notice
|
97 | > and this permission notice appear in all copies.
|
98 | >
|
99 | > THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
100 | > REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
101 | > FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
102 | > INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
103 | > OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
104 | > TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
105 | > THIS SOFTWARE.
|
106 |
|
107 |
|
108 | ## Collaboration
|
109 |
|
110 | If you have questions or issues, please [open an issue][issue]!
|
111 |
|
112 |
|
113 | [1]: https://github.com/ericclemmons/react-resolver/blob/v1/README.md
|
114 | [2]: https://github.com/ericclemmons/react-resolver/blob/v2/README.md
|
115 | [changelog]: https://github.com/ericclemmons/react-resolver/blob/master/CHANGELOG.md
|
116 | [demo]: https://cdn.rawgit.com/ericclemmons/react-resolver/master/examples/stargazers/public/index.html
|
117 | [issue]: https://github.com/ericclemmons/react-resolver/issues/new
|
118 | [license]: https://github.com/ericclemmons/react-resolver/blob/master/LICENSE
|
119 | [twitter]: https://twitter.com/ericclemmons/
|
120 | [upcoming]: https://github.com/ericclemmons/react-resolver/blob/master/CHANGELOG.md#upcoming
|