gabergg / react-scrollable-anchor

Smooth scrolling anchors bound to URL hash
MIT License
291 stars 89 forks source link

Error when using stateless component as child #45

Open igorsantos07 opened 6 years ago

igorsantos07 commented 6 years ago

This could be solved by #19. As a workaround, I'm doing the following:

<ScrollableAnchor id="test">
  <div>
    <MyStatelessComponent/>
  </div>
</ScrollableAnchor>

The error is as follows:

Warning: Stateless function components cannot be given refs. Attempts to access this ref will fail. Check the render method of ScrollableAnchor.

Then, it also throws what's described in #43. Using the div hack solves the matter.

igorsantos07 commented 6 years ago

An even better workaround for both this and #19 at the same time: <ScrollableAnchor id="test"><div/><ScrollableAnchor>