React-ESC-Resolver
Async-rendering & data-fetching for universal React applications.
React ESC Resolver lets you define data requirements per-component
and will handle the nested, async rendering on both the server & client for you.
For example, the following will load & provide this.props.user
for the
UserProfile
component:
import { resolve } from 'react-esc-resolver';
@resolve('user', function(props) {
return http.get(`/api/users/${props.params.userId}`);
})
class UserProfile extends React.Component {
render() {
const { user } = this.props;
...
}
}
This is the equivalent to asynchronously loading user
and providing it to
the component as if it were provided directly:
<UserProfile user={user} />
This makes components pure, stateless, and easy to test as a result.
Installation
$ npm install --save react-esc-resolver
Development
If you'd like to contribute to this project, all you need to do is clone
this project and run:
$ npm install
You can use npm link
to use your development version in your own project:
- Go to
react-esc-resolver
directory and execute command npm link
- Go to your project directory and execute command
npm link react-esc-resolver
React ESC is MIT licensed.
Collaboration
If you have questions or issues, please open an issue!