react-adopt
Advanced tools
Comparing version 0.2.5 to 0.2.6
{ | ||
"name": "react-adopt", | ||
"version": "0.2.5", | ||
"version": "0.2.6", | ||
"main": "dist/index.js", | ||
"umd:main": "dist/index.umd.js", | ||
"module": "dist/index.m.js", | ||
"types": "dist/index.d.ts", | ||
"source": "src/index.tsx", | ||
@@ -8,0 +9,0 @@ "license": "MIT", |
@@ -47,3 +47,3 @@ :sunglasses: _**React Adopt -**_ Compose render props components like a pro | ||
Now you can use adopt to compose your components. See above an example using the awesome [react-powerplug](https://github.com/renatorib/react-powerplug): | ||
Now you can use adopt to compose your components. See bellow an example using the awesome [react-powerplug](https://github.com/renatorib/react-powerplug): | ||
@@ -77,3 +77,3 @@ ![Good](https://i.imgur.com/RXVlFwy.png) | ||
Some components don't use the `children` property as render props. For cases like that, you can pass a function as mapper value that will return your component. This function will receive as props the `render` method, the props passed on `Composed` component and the previous values from each mapper. See an example: | ||
Some components don't use the prop called `children` to make work render props. For cases like that, when you define your mapper you can pass a simple function as mapper value that will return your component, instead of a jsx element. This function will receive a prop `render` that will be responsible to make render, the props passed on `Composed` component and the previous values from each mapper. See an example: | ||
@@ -115,2 +115,24 @@ ```js | ||
And get previous mapper results as prop for compose: | ||
```js | ||
import { adopt } from 'react-adopt' | ||
import { User, Cart, ShippingRate } from 'my-containers' | ||
const Composed = adopt({ | ||
cart: <Cart />, | ||
user: <User />, | ||
shippingRates: ({ user, cart, render }) => ( | ||
<ShippingRate zipcode={user.zipcode} items={cart.items}> | ||
{render} | ||
</ShippingRate> | ||
) | ||
}) | ||
<Composed> | ||
{({ cart, user, shippingRates }) => /* ... */ } | ||
</Composed> | ||
``` | ||
### Leading with multiples params | ||
@@ -117,0 +139,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
20309
203