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

Animating Reactstrap components #45

Open
Stahlion opened this issue Jan 27, 2018 · 3 comments
Open

Animating Reactstrap components #45

Stahlion opened this issue Jan 27, 2018 · 3 comments

Comments

@Stahlion
Copy link

Hey,
Thanks for an awesome package azazdeaz!

Reading your answers in here #3, is it then true that I cannot use & animate e.g. Reactstrap components (like Card) with react-gsap-enhancer?
Meaning, you can ONLY apply the package on primitive tags like divs and spans etc(?)

I'm getting a bunch of

Warning: Stateless function components cannot be given refs. Attempts to access this ref will fail.

Check the render method of 'GSAP(Box)'.
    in Card (at Box.js:32)
    in div (at Box.js:31)
    in GSAP(Box) (at index.js:10)

..when doing:

render() {
    return (
      <div>
        <Card>{this.props.name}</Card>
      </div>
    );
}
export default GSAP()(Box);

Guess it will work anyway being only warnings and all though..

@davidwieler
Copy link

Seeing the same thing myself

@ghost
Copy link

ghost commented Mar 23, 2018

+1

@benstepp
Copy link
Collaborator

Some of the reactstrap components support the innerRef attribute which allows
you to ref the DOM node of the rendered component. In your specific example
using <Card /> it does not. However, you should be able to get around this by
using the tag attribute and passing a custom component.

import { Card } from 'reactstrap'

const MagicalDiv = ({ innerRef, ...rest }) => <div ref={innerRef} {...rest} />
export default class RefableCard extends React.Component {
  render() {
    <Card {...this.props} tag={MagicalDiv} />
  }
}

This is just a wrapper around the reactstrap card that knows how to pass the
prop innerRef to the rendered DOM card. Definitely not ideal, but it should
work to give you refs to DOM nodes. You would import it and use it exactly like
a card, but you can now pass innerRef to the <Card /> and get a DOM node.


They have an open issue: reactstrap/reactstrap#877 talking about refs.

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