mickaelchanrion/rolly

using with react?

sbtly opened this issue ยท 3 comments

sbtly commented

Hi. Thank you for this amazing lib!

I really want to use it in my react project, but somehow it doesn't work and I don't know why.
These 3 options all doesn't work. It gives me 'TypeError: Cannot read property 'querySelectorAll' of null' error.

const rollyView = this.rolly.current;
const rollyView = ReactDOM.findDOMNode(this.rolly.current);
const rollyView = document.querySelector('.App');

I made an example in codesandbox, hope you can help.

https://codesandbox.io/s/reverent-joliot-gewsi?fontsize=14&hidenavigation=1&theme=dark

Hey!
Just took a look at your codesandbox. I think it's because of a typo here:

const Rolly = rolly({ rollyView, native: true });

The option rollyView doesn't exist.

This should do the job:

const scroll  = rolly({ view: this.rolly.current, native: true });
scroll.init();

Note:
I noticed that you are using capital letters for the variable Rolly. Please keep in mind that historically, those are reserved for instantiable classes to avoid confusion ๐Ÿ˜‰

sbtly commented

oh, you're right!
view: rollyView fixed it.
Thank you so much! ๐Ÿ˜Š

sbtly commented

By the way, do you have plan to write react version of this lib?
It would be so great.