Closed JosephClay closed 5 years ago
Refactoring to componentDidUpdate
required a deep-equality check to keep from going into an infinite loop: https://www.npmjs.com/package/deep-equal
Hook useBranch
and hook tests have been added, mimicking higher-order's tests
Hello @JosephClay
remove mixins?
Probably not. I still know people using them and I feel it would be sad to leave them behind (even by bumping a major version).
Did you write docs for the hooks?
@arnaudmolo can I ask you for your opinion on those hooks?
@Yomguithereal Haven't created documentation yet
Would this be the way you like the hook to be exposed?
import { useBranch } from 'baobab-react/higher-order';
Maybe more:
import { useBranch } from 'baobab-react/hooks';
Also should we move to new context APIs?
The hook can't work on its own, it still needs a rooted top-level component to consume the Context. I can note that in the documentation
New context APIs were the first things added to remove getChildContext
The hook looks ok, as you both stated we would need it in the doc.
I'm just wondering, what will be the price of replacing ComposedComponent & co with functionnal components ? I'm guessing it could be done with hooks, bu I don't really know baobab's code base.
@Yomguithereal @arnaudmolo I've added documentation for hooks, based off higher-order. In fact, with the refactor to using the new Context API, higher-order and hooks are interoperable!
I've added the hook useRoot
to be consistent
Added dispatch
to the useBranch
hook for parity with higher-order and added action tests
Seems good to me. I just have a remark on the docs I listed herebefore. @arnaudmolo everything's good for you?
@Yomguithereal 👍
I am going to merge this. @JosephClay should this be a v4 or can this be a safe v3.1?
@Yomguithereal I believe a v4 would be in order, as the Context API requires React ^16.x
. Has the potential to break projects using higher-order
with an older version of React
Fair enough. Let's go then :)
v4.0.0 is now live on npm. Thanks @JosephClay.
First steps of updating the library to remove legacy
getChildContext
APINext steps:
componentWillMount
logic to the constructorcomponentWillReceiveProps
withcomponentDidUpdate
useBranch
hookremove mixins@Yomguithereal does this sound like a good plan?