react-adopt
Advanced tools
Comparing version 0.2.2 to 0.2.3
{ | ||
"name": "react-adopt", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"main": "dist/index.js", | ||
@@ -73,5 +73,2 @@ "umd:main": "dist/index.umd.js", | ||
}, | ||
"engines": { | ||
"node": ">=9.0.0" | ||
}, | ||
"lint-staged": { | ||
@@ -78,0 +75,0 @@ "src/**.tsx": [ |
@@ -11,6 +11,9 @@ :sunglasses: _**React Adopt -**_ Compose render props components like a pro | ||
- [Why](#why) | ||
- [Usage](#usage) | ||
- [Why](#--why) | ||
- [Solution](#--solution) | ||
- [Demos](#--demos) | ||
- [Usage](#--usage-demo) | ||
- [Working with new Context api](#working-with-new-context-api) | ||
- [Custom render and retrieving props from composed](#custom-render-and-retrieving-props-from-composed) | ||
- [Leading with multiple params](#leading-with-multiple-params) | ||
- [Typescript support](#typescript-support) | ||
@@ -20,3 +23,3 @@ | ||
[Render Props](https://reactjs.org/docs/render-props.html) are the new hype of React's ecossystem, that's a fact. So, when you need to use more than one render props component together, this can be boring and generate something called a *"render props callback hell"*, like that: | ||
[Render Props](https://reactjs.org/docs/render-props.html) are the new hype of React's ecosystem, that's a fact. So, when you need to use more than one render props component together, this can be boring and generate something called a *"render props callback hell"*, like that: | ||
@@ -32,4 +35,10 @@ ![Bad](https://i.imgur.com/qmk3Bk5.png) | ||
## 💻 Usage ([demo](https://codesandbox.io/s/vq1wl37m0y?hidenavigation=1)) | ||
## 📟 Demos | ||
- [Basic example](https://codesandbox.io/s/vq1wl37m0y?hidenavigation=1) | ||
- [Todo App example using React Apollo](https://codesandbox.io/s/3x7n8wyp15?hidenavigation=1) | ||
- [Example with new Context API](https://codesandbox.io/s/qv3m6yk2n4?hidenavigation=1) | ||
## 💻 Usage | ||
Install as project dependency: | ||
@@ -66,2 +75,4 @@ | ||
See [this demo](https://codesandbox.io/s/qv3m6yk2n4?hidenavigation=1) for a better comprehension | ||
### Custom render and retrieving props from composed | ||
@@ -106,2 +117,32 @@ | ||
### Leading with multiples params | ||
Some render props components return multiple arguments in the children function instead of single one, a simple example in the new [Query](https://www.apollographql.com/docs/react/essentials/queries.html#basic) and [Mutation](https://www.apollographql.com/docs/react/essentials/mutations.html) component from `react-apollo`. In that case, what you can do is a arbitrary render with `render` prop [using you map value as a function](#custom-render-and-retrieving-props-from-composed): | ||
```js | ||
import { adopt } from 'react-adopt' | ||
import { Mutation } from 'react-apollo' | ||
const ADD_TODO = /* ... */ | ||
const addTodo = ({ render }) => ( | ||
<Mutation mutation={ADD_TODO}> | ||
{/* that's is arbitrary render where you will pass your two arguments into single one */} | ||
{(mutation, result) => render({ mutation, result })} | ||
</Mutation> | ||
) | ||
const Composed = adopt({ | ||
addTodo, | ||
}) | ||
const App = () => ( | ||
<Compose> | ||
{({ addTodo: { mutation, result } }) => /* ... */} | ||
</Compose> | ||
) | ||
``` | ||
See [this demo](https://codesandbox.io/s/3x7n8wyp15?hidenavigation=1) for a complete explanation about that. | ||
### Typescript support | ||
@@ -108,0 +149,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 3 instances in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
3
181
0
19625
14
230