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

Render fixes #19

Merged
merged 3 commits into from
May 15, 2016
Merged

Render fixes #19

merged 3 commits into from
May 15, 2016

Conversation

rafeememon
Copy link
Contributor

This PR fixes a couple issues I ran into:

  • I was still having difficulty setting the renderElementTo node after Problem with renderElementTo #16 was closed. I think the root of the problem is that since the render node is computed as soon as the TetherComponent is mounted, it doesn't "give me a chance" to find the node I want to render into. If we instead lazily evaluate the node retrieval (i.e. only in update) we can specify nodes that might not exist yet.
  • Commit 78859dd restricted renderElementTo to a string (i.e. a query selector) but sometimes it may not be possible to give a selector; for instance if the target is a React component, all that is available is the DOM element (adding IDs/classes for this seems very anti-React). This adds the ability to specify either a query selector or a DOM node.

@rafeememon
Copy link
Contributor Author

Hey @souporserious, what do you think of this? It's currently blocking react-datepicker's upgrade to React v15 since the API change happened before the bump to v15

@@ -30,7 +30,7 @@ const attachmentPositions = [
class TetherComponent extends Component {
static propTypes = {
renderElementTag: PropTypes.string,
renderElementTo: PropTypes.string,
renderElementTo: PropTypes.any,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use React.PropTypes.oneOfType here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes @rafeememon please implement oneOfType here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the oneOfType be [PropTypes.string, PropTypes.any]? This is equivalent to PropTypes.any =P

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should either be a string or a DOM node. So i'm guessing we would need a custom proptype checking if it's a DOM element? Something like this http://stackoverflow.com/a/385427/1461204

@souporserious
Copy link
Collaborator

@rafeememon so sorry I just saw this. It's been a crazy last month. This all looks great! Just one thing, can we use a getter for this._getRenderNode() and change it back to this._renderNode? Once that's done I can merge this in.

@chibicode
Copy link

chibicode commented May 14, 2016

For those of us who came from this issue: Hacker0x01/react-datepicker#444 (comment) - react-datepicker can already be upgraded to React v15 as react-datepicker is inlining TetherComponent. Thanks @rafeememon and @souporserious for your work!

@rafeememon
Copy link
Contributor Author

Added an appendChild duck type and a getter for _renderNode

@souporserious
Copy link
Collaborator

Thanks for the work on this! Merged :)

@souporserious souporserious reopened this May 15, 2016
@souporserious souporserious merged commit 7d04d15 into danreeves:master May 15, 2016
@rafeememon rafeememon deleted the feature/render-fixes branch May 16, 2016 16:47
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

Successfully merging this pull request may close these issues.

None yet

4 participants