libreact icon indicating copy to clipboard operation
libreact copied to clipboard

FaCC composition

Open streamich opened this issue 6 years ago • 3 comments

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]);

streamich avatar May 03 '18 13:05 streamich

This structure seems too complex for my understanding, can you also show example usage? Also it should be FaaC - Function as a Child

ackvf avatar May 09 '18 16:05 ackvf

@ackvf Here is an example usage: https://github.com/reactjs/rfcs/pull/47#issuecomment-385005257

streamich avatar May 09 '18 16:05 streamich

FaCC — Function as Child Component

streamich avatar May 09 '18 16:05 streamich