Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/facebookexperimental/Recoil
Recoil is an experimental state management library for React apps. It provides several capabilities that are difficult to achieve with React alone, while being compatible with the newest features of React.
https://github.com/facebookexperimental/Recoil
Last synced: 11 days ago
JSON representation
Recoil is an experimental state management library for React apps. It provides several capabilities that are difficult to achieve with React alone, while being compatible with the newest features of React.
- Host: GitHub
- URL: https://github.com/facebookexperimental/Recoil
- Owner: facebookexperimental
- License: mit
- Created: 2020-05-04T19:44:15.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-10-23T08:07:41.000Z (13 days ago)
- Last Synced: 2024-10-24T00:08:39.453Z (12 days ago)
- Language: JavaScript
- Homepage: https://recoiljs.org/
- Size: 47.5 MB
- Stars: 19,600
- Watchers: 197
- Forks: 1,186
- Open Issues: 321
-
Metadata Files:
- Readme: README-recoil-relay.md
- Changelog: CHANGELOG-recoil-relay.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome - facebookexperimental/Recoil - Recoil is an experimental state management library for React apps. It provides several capabilities that are difficult to achieve with React alone, while being compatible with the newest features of React. (JavaScript)
- awesome-react-cn - recoil - Experimental state management library for React apps (Uncategorized / Uncategorized)
- awesomeLibrary - Recoil - Recoil is an experimental state management library for React apps. It provides several capabilities that are difficult to achieve with React alone, while being compatible with the newest features of React. (语言资源库 / JavaScript)
- awesome-react - recoil - Experimental state management library for React apps. ![](https://img.shields.io/github/stars/facebookexperimental/Recoil.svg?style=social&label=Star) (Utilities / State Management)
- Algorithms-Cheatsheet-Resources - Recoil - An experimental state management library for React apps
- awesome-learning-resources - recoil - Experimental state management library for React apps (Uncategorized / Uncategorized)
- awesome-web-react - Recoil - A Facebook experimental state management library for complex React UIs. (State Management)
- awesome-list - Recoil
- best-of-react - GitHub - 29% open · ⏱️ 07.09.2023): (State Management)
- awesome-react-state-management - recoil - Recoil is an experimental state management library for React apps. It provides several capabilities that are difficult to achieve with React alone, while being compatible with the newest features of React. (List)
- awesome-f2e-libs - **recoil**
- awesome-react-cn - recoil
- awesome-react - recoil - Experimental state management library for React apps (**Awesome React** [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome) / React)
- awesome-star-libs - facebookexperimental / Recoil
- awesome-react - recoil - Recoil is an experimental state management library for React apps. It provides several capabilities that are difficult to achieve with React alone, while being compatible with the newest features of React. ` 📝 4 days ago` (React [🔝](#readme))
README
# Recoil Relay · [![NPM Version](https://img.shields.io/npm/v/recoil-relay)](https://www.npmjs.com/package/recoil-relay) [![Node.js CI](https://github.com/facebookexperimental/Recoil/workflows/Node.js%20CI/badge.svg)](https://github.com/facebookexperimental/Recoil/actions) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/facebookexperimental/Recoil/blob/main/LICENSE) [![Follow on Twitter](https://img.shields.io/twitter/follow/recoiljs?label=Follow%20Recoil&style=social)](https://twitter.com/recoiljs)
The `recoil-relay` library helps [Recoil](https://recoiljs.org) perform type safe and efficient queries using [GraphQL](https://graphql.org/) with the [Relay](https://relay.dev) library.
Please see the [**Recoil Relay GraphQL Documentation**](https://recoiljs.org/docs/recoil-relay/introduction)
`recoil-relay` provides `graphQLSelector()` and `graphQLSelectorFamily()` selectors which can easily query with GraphQL. The queries are synced with the Recoil data-flow graph so downstream selectors can derive state from them, they can depend on upstream Recoil state, and they are automatically subscribed to any changes in the graph from Relay. Everything stays in sync automatically.
## Example
After setting up your Relay environment adding a GraphQL query is as simple as defining a [GraphQL selector](https://recoiljs.org/docs/recoil-relay/graphql-selectors).```jsx
const userNameQuery = graphQLSelector({
key: 'UserName',
environment: myEnvironment,
query: graphql`
query UserQuery($id: ID!) {
user(id: $id) {
name
}
}
`,
variables: ({get}) => ({id: get(currentIDAtom)}),
mapResponse: data => data.user?.name,
});
```
Then use it like any other Recoil [selector](https://recoiljs.org/docs/api-reference/core/selector):
```jsx
function MyComponent() {
const userName = useRecoilValue(userNameQuery);
return {userName};
}
```## Installation
Please see the [Recoil installation guide](https://recoiljs.org/docs/introduction/installation) for installing Recoil and the [Relay documentation](https://relay.dev/docs/getting-started/installation-and-setup/) for installing and setting up the Relay library, GraphQL compiler, Babel plugin, and ESLint plugin. Then add `recoil-relay` as a dependency.
## Contributing
Development of Recoil happens in the open on GitHub, and we are grateful to the community for contributing bugfixes and improvements. Read below to learn how you can take part in improving Recoil.
- [Code of Conduct](./CODE_OF_CONDUCT.md)
- [Contributing Guide](./CONTRIBUTING.md)### License
Recoil is [MIT licensed](./LICENSE).