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

feature idea: pass size as prop to child #5

Open
mdarens opened this issue Dec 8, 2015 · 9 comments
Open

feature idea: pass size as prop to child #5

mdarens opened this issue Dec 8, 2015 · 9 comments

Comments

@mdarens
Copy link

mdarens commented Dec 8, 2015

This would allow custom behavior in children without registering a callback function. What do you think?

@joeybaker
Copy link
Owner

Sure! I'll take a PR!

@mdarens
Copy link
Author

mdarens commented Dec 8, 2015

Should it be opt-in? Something along the lines of a string sizeProp prop on the ElementQuery instance which determines the name of the prop which gets passed through?

@joeybaker
Copy link
Owner

Great idea. Maybe, if that prop is left undefined, we don't pass it down?

@mdarens
Copy link
Author

mdarens commented Dec 8, 2015

I'm having trouble getting the tests to run on my system, but I was thinking something like this:

In the render method:

    const sizeProp = this.props.sizeProp ? {
      name: this.props.sizeProp,
      value: className
    } : null;

then pass sizeProp as a third arg to makeChild and in makeChild:

    const sizePropName = sizeProp ? sizeProp.name : null
    const sizePropValue = sizeProp ? sizeProp.value : null

    return cloneElement(child, {className: classNames.join(' '), [sizePropName]: sizePropValue})

@joeybaker
Copy link
Owner

Seems right!

@gajus
Copy link

gajus commented May 9, 2017

This feature has not been implemented?

In addition to passing the size, I'd like to able to pass custom values dependant on the size.

The use case is elementary: I need to load different data depending on whats the container size.

@joeybaker
Copy link
Owner

@gajus It hasn't. I'd happily take a PR!

@gajus
Copy link

gajus commented May 9, 2017

@joeybaker Would you consider handing over the namespace of the project?

I'd happily take over the development seeing that this is a requirement inherent in the project I will be working on for a foreseeable future.

There are quite a few things that I'd like to do different, starting with (1) using compile time to wrap react-element-query in an if statement (to prevent them from being mounted) (2) allow user supplied mechanism for detecting container element dimensions.

(Otherwise I will just start working on it under a different name.)

@joeybaker
Copy link
Owner

@gajus I'm very interested in adding you as an owner/collaborator! Let's start with a PR or two? Assuming we mostly see eye-to-eye on things, I'm more than happy to share responsibility.

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

3 participants