Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-adopt

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-adopt - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

CONTRIBUTING.md

5

package.json
{
"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": [

49

README.md

@@ -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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc