Skip to content

Releases: pedronauck/react-adopt

v0.6.0

12 May 20:54
Compare
Choose a tag to compare

Changelog

  • Add support to pass a component as mapper value
  • Hoisting non-react statics methods from mapper value to Composed component (thanks @russelh15)
import { React } from 'react'
import { adopt } from 'react-adopt'
import { Value } from 'react-powerplug'

const Greeter = ({ render, name }) => render(`Hi ${name.value}`)

Greeter.sayHi = (name) => `Hi ${name}`

const Composed = adopt({
  name: <Value name="John" />
  greet: Greet
})

console.log(Composed.sayHi('John')) // Hi John

const App = () => (
  <Composed>
    {({ greet, name }) => /* ... */ }
  </Composed>
)

v0.5.1

11 May 05:13
Compare
Choose a tag to compare

Changelog

  • Add render prop to composed component (thanks @ctrlplusb for the idea)
  • Improve some types
import { adopt } from 'react-adopt'
import { Value } from 'react-powerplug'

const Composed = adopt({
  foo: <Value initial="foo" />
})

const App = () => (
  <Composed render={({ foo }) => /* ... */ } />
)

v0.4.1

28 Apr 02:44
Compare
Choose a tag to compare

Changelog

  • Feat: add map props feature (1ae14f8)
import { adopt } from 'react-adopt'
import { Value } from 'react-powerplug'

const Composed = adopt({
  greet: <Value initial="Hi" />,
  name: <Value initial="John" />,                                   
},
// mapping props from results
({ greet, name }) => ({
  message: `${greet.value} ${name.value}`,
}))

const App = () => (
  <Composed>
    {({ message }) => /* ... */}
  </Composed>
)

v0.3.3

27 Apr 15:14
Compare
Choose a tag to compare

Changelog

  • Fix: don't recreate adopt instance in every render (#12)

Thanks @renatorib ✌️

v0.3.1

07 Apr 01:30
Compare
Choose a tag to compare

Changelog

Inline composition

If you dont care about typings and need something more easy and quick, you can choose to use a inline composition by importing <Adopt> component and passing your mapper as prop:

import React from 'react'
import { Adopt } from 'react-adopt'
import { Value } from 'react-powerplug'

const mapper = {
  greet: <Value initial="Hi" />,
  name: <Value initial="John" />
}

<Adopt mapper={mapper}>
  {({ greet, name }) => /* ... */}
</Adopt>

v0.2.9

06 Apr 18:53
Compare
Choose a tag to compare

Changelog

  • Improve readme with some exampels
  • Fix: add types and files fields on package.json
  • Fix: optional types for render props
  • Fix: typescript definitions

v0.2.3

03 Apr 20:56
Compare
Choose a tag to compare

Changelog

  • Remove required node engine from package.json
  • Add a lot of improvements on readme

v0.2.2

01 Apr 04:43
Compare
Choose a tag to compare

Changelog

  • Improve typescript support
  • Improve readme with some examples of usage

v0.2.1

31 Mar 22:17
Compare
Choose a tag to compare

Changelog

  • Add support to pass a function as mapper value
  • Add support to retrieving props from composed
  • Add support for component with custom renderprops

More info about these features on readme

Thanks for @lucasconstantino ✌️

v0.1.2

30 Mar 04:09
Compare
Choose a tag to compare

Changelog

  • Some documentation improvements