Comments (5)
Not sure about this. If you need to use componentDidMount()
or any of the other component lifecycle methods, at that point you should probably use a class component.
from recompose.
Thanks for the response, and I totally understand if you don't want to include this feature at the moment, but just for discussion now:
This library covers most of the useful Component
API surface, which I think componentDidMount()
is in at least in the case that I mentioned, and its stated intention seems to be to eliminate the need for extending Component
or calling React.createClass
in favor of functional style, so I guess I'm having a hard time understanding why componentDidMount()
would not qualify. Could you explain why you think componentDidMount()
is better handled by extending Component
?
from recompose.
IMHO:
The most common case in componentDidMount is to use refs
for component Dom events, for jQuery plugins like integration,
(the other case is for events like resize
)
But internal refs
for stateless component is gone every new render, (and stateless component doesn't have each own ref
) so it's impossible to use this common case.
Also how to access internal component refs without some hackable api?
from recompose.
I definitely see where you are coming from and agree when it comes to using refs
. Another example that I have frequently encountered, however, is for components that need to update state on window
scroll events for some visual effect, virtualization purposes, etc. In these cases refs
haven't been necessary but I do need to call window.addEventListener()
on the client. I get that this use case might be too specific to warrant inclusion in the library itself. It would be totally fine to write a custom HoC and use compose()
-- excellent API design, btw 😄
Thanks!
from recompose.
I'm hesitant to add support for other lifecycle methods because lifecycle methods usually need to call setState()
or save references to a subscription on the component instance. Both of these go against the functional nature of Recompose's API. I'm still not sure if the existing lifecycle()
helper shouldn't be removed.
I'm going to close this issue, but if you have an idea for an API, please let me know :)
from recompose.
Related Issues (20)
- renderNothing should export Nothing HOT 4
- Does TypeScript 3.4 enable typing of compose HOT 1
- Remove flow types in repo and support only in flow-typed repo HOT 1
- Key advantages in Docs HOT 2
- The best way to test a component that use getContext recompose HOT 1
- Get a lifecycle componentDidMount unmounted error HOT 1
- Rewriting mapPropsStream with Hooks or new Lifecycle Methods HOT 4
- compose hoc causes to lose typings
- Remove usage of `createFactory` HOT 4
- Why does `mapProps` remove `children`? HOT 2
- node-fetch vulnerability issue (denial of service) HOT 8
- Forked, Updated, and Published HOT 1
- fbjs dependency still present in lock file HOT 3
- Support React 17 HOT 2
- Suggest alternative to branch(), renderComponent(), renderNothing(), compose(), etc
- TypeError: Cannot read properties of undefined (reading 'apply')
- Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
- New patch required to mitigate high risk vulnerability
- Maintainers HOT 1
- This is GITHUB and not the European Parliament or NATO.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from recompose.