eiriklv / react-masonry-component

A React.js component for using @desandro's Masonry
MIT License
1.44k stars 145 forks source link

Ref problem. #87

Closed EmilioHerreraSoukup closed 7 years ago

EmilioHerreraSoukup commented 7 years ago

I get the error:

addComponentAsRefTo(...): Only a ReactOwner can have refs. You might be adding a ref to a component that was not created inside a component's render method, or you have multiple copies of React loaded (details: https://fb.me/react-refs-must-have-owner).

any help would be appreciated.

afram commented 7 years ago

Hi @EmilioHerrera

Is this still an issue? Do you have a code example?

afram commented 7 years ago

Hi @EmilioHerrera

I'm going to close this issue. Please feel free to reopen if needed :-)

chenfengyanyu commented 7 years ago

I have the same problem,this is my code:

import PropTypes from 'prop-types';
import React from 'react';
import Masonry from 'react-masonry-component';
import styles from './index.less';

const Waterfall = ({ lists }) => {
  let masonryOptions = {
    transitionDuration: 0,
  };
  let childElements = lists.map((item) => {
    return (
      <li key={item.id} className="image-element-class">
        <img alt="" src={item.src} />
      </li>
    );
  });

  return (
    <Masonry
      className={'my-gallery-class'} // default ''
      elementType={'ul'} // default 'div'
      options={masonryOptions} // default {}
      disableImagesLoaded={false} // default false
      updateOnEachImageLoad={false} // default false and works only if disableImagesLoaded is false
    >
      {childElements}
    </Masonry>
  );
};

Waterfall.propTypes = {
};

export default Waterfall;
afram commented 7 years ago

Hi @chenfengyanyu,

What version of React are you using?

chenfengyanyu commented 7 years ago

@afram this is what I used in my project:

"react": "^15.4.0",
"react-dom": "^15.4.0",
"react-masonry-component": "^5.0.7",
xywenke commented 6 years ago

The same with me, my packages version list as below

"react": "^16.0.0",
"react-dom": "^16.0.0",
"react-masonry-component": "^6.0.0",

Could someone can help me? Thanks a lot.