|
| 1 | +# React-ESC-Resolver  [](https://github.com/tripss/react-esc-resolver/issues) [](https://david-dm.org/tripss/react-esc-resolver#info=dependencies) |
| 2 | + |
| 3 | +> Async-rendering & data-fetching for universal React applications. |
| 4 | +
|
| 5 | +###### This project is based on [react-resolver](https://github.com/ericclemmons/react-resolver) |
| 6 | +React ESC Resolver lets you **define data requirements _per-component_** |
| 7 | +and will **handle the nested, async rendering on both the server & client for you.** |
| 8 | + |
| 9 | +For example, the following will load & provide `this.props.user` for the |
| 10 | +`UserProfile` component: |
| 11 | + |
| 12 | +```js |
| 13 | +import { resolve } from 'react-esc-resolver'; |
| 14 | + |
| 15 | +@resolve('user', function(props) { |
| 16 | + return http.get(`/api/users/${props.params.userId}`); |
| 17 | +}) |
| 18 | +class UserProfile extends React.Component { |
| 19 | + render() { |
| 20 | + const { user } = this.props; |
| 21 | + ... |
| 22 | + } |
| 23 | +} |
| 24 | +``` |
| 25 | + |
| 26 | +This is the equivalent to asynchronously loading `user` and providing it to |
| 27 | +the component as if it were provided directly: |
| 28 | + |
| 29 | +```xml |
| 30 | +<UserProfile user={user} /> |
| 31 | +``` |
| 32 | + |
| 33 | +This makes components _pure_, _stateless_, and _easy to test_ as a result. |
| 34 | + |
| 35 | + |
| 36 | +### Installation |
| 37 | +```shell |
| 38 | +$ npm install --save react-esc-resolver |
| 39 | +``` |
| 40 | + |
| 41 | +## Development |
| 42 | + |
| 43 | +If you'd like to contribute to this project, all you need to do is clone |
| 44 | +this project and run: |
| 45 | + |
| 46 | +```shell |
| 47 | +$ npm install |
| 48 | +$ npm test |
| 49 | +``` |
| 50 | + |
| 51 | +## [License](https://github.com/tripss/react-esc-resolver/blob/master/LICENSE) |
| 52 | + |
| 53 | +> Internet Systems Consortium license |
| 54 | +> =================================== |
| 55 | +> |
| 56 | +> The MIT License (MIT) |
| 57 | +> |
| 58 | +> Copyright (c) 2015 David Zukowski |
| 59 | +> |
| 60 | +> Permission is hereby granted, free of charge, to any person obtaining a copy |
| 61 | +> of this software and associated documentation files (the "Software"), to deal |
| 62 | +> in the Software without restriction, including without limitation the rights |
| 63 | +> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 64 | +> copies of the Software, and to permit persons to whom the Software is |
| 65 | +> furnished to do so, subject to the following conditions: |
| 66 | +> |
| 67 | +> The above copyright notice and this permission notice shall be included in all |
| 68 | +> copies or substantial portions of the Software. |
| 69 | +> |
| 70 | +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 71 | +> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 72 | +> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 73 | +> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 74 | +> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 75 | +> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 76 | +> SOFTWARE. |
| 77 | +
|
| 78 | +## Collaboration |
| 79 | + |
| 80 | +If you have questions or issues, please [open an issue](https://github.com/TriPSs/react-esc-resolver/issues)! |
0 commit comments