libreact
libreact copied to clipboard
FaCC composition
Implement FaCC composition helper, as suggested here:
- https://github.com/reactjs/rfcs/pull/47#issuecomment-385005257
const wrap = (faccs, params, callback) => {
if (!faccs.length) {
return callback(...params);
}
const [Comp, ...restFaccs] = faccs;
return React.createElement(Comp, null, (...args) => {
params.push(args.length > 1 ? args : args[0]);
return wrap(restFaccs, params, callback);
});
};
const userspaceSolution = (...args) =>
wrap(args.slice(0, args.length - 1), [], args[args.length - 1]);
This structure seems too complex for my understanding, can you also show example usage? Also it should be FaaC
- Function as a Child
@ackvf Here is an example usage: https://github.com/reactjs/rfcs/pull/47#issuecomment-385005257
FaCC — Function as Child Component