Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fillChildProps cannot pass functions through to fill #26

Open
TimoStaudinger opened this issue Oct 12, 2017 · 1 comment
Open

fillChildProps cannot pass functions through to fill #26

TimoStaudinger opened this issue Oct 12, 2017 · 1 comment

Comments

@TimoStaudinger
Copy link

Passing functions through to fills is currently not possible. Instead they are called during the transform step:

const value = fillChildProps[key];

if (typeof value === 'function') {
    acc[key] = () => value(fill, this.fills);
} else {
    acc[key] = value;
}

This prevents us from passing callbacks like onChange into fills.

Reading the readme, this seems to be by design:

  /**
   * Props to be applied to the child Element of every fill which has the same name.
   *
   *  If the value is a function, it must have the following signature:
   *    (target: Fill, fills: Fill[]) => void;
   *
   *  This allows you to access props on the fill which invoked the function
   *  by using target.props.something()
   */
  fillChildProps?: {[key: string]: any}

Could you please help me understand why this is the case? If the main use case is to get a 'ref' to the fill, wouldn't it be nicer and less limiting to make that a separate property?

@camwest
Copy link
Owner

camwest commented Nov 3, 2017

I honestly forget. Can you look in the "advanced" example to see if it's being utilized? If you want to redesign this bit can you update the example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants