Support for stateless components
See original GitHub issueI tried to use this lib with recompose:
const controller = compose(
withHandlers({
handleClickOutside: (props) => (event) => null // do something
}),
onClickOutside
);
const component = controller((props) => <div>...</div>);
Unfortunately, onClickOutside HOC expects component with handleClickOutside
method defined in component itself, so it doesn’t work with stateless components.
Right now I’m using simple component using existing API which I use a root component in my stateless one:
@onClickOutside
class OutsideClickHandler extends Component {
handleClickOutside() {
this.props.handleClickOutside();
}
render() {
return this.props.children;
}
}
Question is: Is it worth to include such a component in this library? Is there a better way how to support stateless components or take handler function from props?
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Stateful and Stateless Components in React
Today, we're going to review what stateful and stateless components are in React, how you can tell the difference, and the complex process ......
Read more >Stateless Components From Stateful Components Cheatsheet
In React, a stateful component is a component that holds some state. Stateless components, by contrast, have no state. Note that both types...
Read more >What are the advantages of stateless components? - O'Reilly
The answer is performance. Stateless functional components can be rendered faster. One of the reasons why this is the case is because stateless...
Read more >React Stateless Functional Components: Nine Wins You Might ...
Stateless functional components don't support state or lifecycle methods. This is a good thing. Why?
Read more >Support functional stateless components · Issue #45 - GitHub
I am currently working on #261, and I have encountered a similar issue. Calling .text() directly on the wrapper does not work for...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Pomax no problem, here’s the new issue: https://github.com/Pomax/react-onclickoutside/issues/127
Hm, this sounds like it needs a new issue filed, specifically to check whether the HOC is wrapping a true component, or just a stateless render function. Want to file one?