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 props #220

Open
techniq opened this issue Jan 3, 2018 · 4 comments
Open

Render props #220

techniq opened this issue Jan 3, 2018 · 4 comments

Comments

@techniq
Copy link
Collaborator

techniq commented Jan 3, 2018

Creating a list of existing HOC components we should updated to have least have a render prop equivalent (feel free to add to the list)

@hshoff
Copy link
Member

hshoff commented Jan 4, 2018

thanks @techniq!

@williaster
Copy link
Collaborator

We could possibly remove TooltipWithBounds if we converted withBoundingRects -> BoundingRects because things could be more composable:

const top = ...;
const left = ...;

<BoundingRects>
  {({ rect, parentRect }) => (
    <Tooltip 
        style={{ 
          top: rect && parentRect && rect.right > parentRect.right ? (left - rect.width) : left, 
          left: rect && parentRect && rect.bottom > parentRect.bottom ? (top - rect.height) : top, 
          ...rest 
     }}>
  )}
</BoundingRects>

though this still requires the user to do the right rect comparison, which isn't hard but is basically boilerplate.

@techniq
Copy link
Collaborator Author

techniq commented Jan 12, 2018

@williaster could BoundingRects expose some helpers passed down as well, such as

const top = ...;
const left = ...;

<BoundingRects>
  {({ rect, parentRect, getTop, getLeft }) => (
    <Tooltip 
        style={{ 
          top: getTop(left), 
          left: getLeft(top), 
          ...rest 
     }}>
  )}
</BoundingRects>

@techniq
Copy link
Collaborator Author

techniq commented Apr 30, 2018

Would be useful if all our shapes supported render props as well, similar to how area now does.

This will be useful to better support react-spring (to allow using animated.rect instead of just rect, etc)

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

No branches or pull requests

3 participants