Currying of higher order components is broken in 2.0.0
demux opened this issue · 1 comments
demux commented
import {branch} from 'baobab-react/higher-order'
import React, {Component} from 'react'
class MyComponent {}
branch({})(MyComponent)
// Will throw an error:
// baobab-react/higher-order.branch: given target is not a valid React component.
My .babelrc
looks like this:
{
"presets": ["es2015", "stage-0", "react"],
"plugins": [
"add-module-exports",
"syntax-trailing-function-commas",
"transform-decorators-legacy"
]
}
I monkey patched it like this for now using lodash
:
import higherOrder from 'baobab-react/higher-order'
import {curry} from 'lodash'
higherOrder.root = curry(higherOrder.root, 2)
higherOrder.branch = curry(higherOrder.branch, 2)
On another note, you might also consider:
- Exporting the uncurried versions of
branch
androot
- Exporting the internal utility library
Yomguithereal commented
Hello @demux. Which version of React do you use? If I remember correctly, on the latest one, if your component's class doesn't extend React.Component then the component is deemed invalid. But there can also be a bug with the lib's currying utility.
Exporting the uncurried versions of branch and root
What is the benefit from doing this?
Exporting the internal utility library
The internal utility library only has a curry function really.