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

feat: Support ref to render props #59

Merged
merged 3 commits into from Jul 9, 2019
Merged

feat: Support ref to render props #59

merged 3 commits into from Jul 9, 2019

Conversation

zombieJ
Copy link
Member

@zombieJ zombieJ commented Jul 9, 2019

添加 ref 代理以支持内部&外部同时获得 dom 节点:

  • 使用 forwardRef (如果支持的话)将 ref 传递给 CSSMotion 处理
  • CSSMotion 本身创建另一个 ref 给 render props 作为代理
const motionRef = React.createRef();

<CSSMotion
  ref={motionRef}
>
  {({ style, className }, ref) => (
    // 由于是 renderProps,需要用户自行把 ref 传递下去
    <div ref={ref} className={className} style={style} />
  )}
</CSSMotion>

@vercel
Copy link

vercel bot commented Jul 9, 2019

This pull request is automatically deployed with Now.
To access deployments, click Details below or on the icon next to each push.

Latest deployment for this branch: https://rc-tree-git-motion-ref.react-component.now.sh

@zombieJ zombieJ requested a review from afc163 July 9, 2019 08:16
@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 83.158% when pulling 05e44d5 on motion-ref into 5f1bf9b on master.

@zombieJ zombieJ merged commit 6f2b47b into master Jul 9, 2019
@delete-merged-branch delete-merged-branch bot deleted the motion-ref branch July 9, 2019 08:28
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

3 participants