Merge pull request #2005 from mattblackdev/devel

Allow passing multiple args to HOCs
This commit is contained in:
Sacha Greif 2018-06-21 09:19:33 +09:00 committed by GitHub
commit 40b91adafe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -57,7 +57,11 @@ export const getComponent = (name) => {
if (!component) {
throw new Error(`Component ${name} not registered.`)
}
const hocs = component.hocs.map(hoc => Array.isArray(hoc) ? hoc[0](hoc[1]) : hoc);
const hocs = component.hocs.map(hoc => {
if(!Array.isArray(hoc)) return hoc;
const [actualHoc, ...args] = hoc;
return actualHoc(...args);
});
return compose(...hocs)(component.rawComponent)
};