Comments (4)
It's weird because clampLines()
with this.element
is being called on componentDidMount()
and a ref already should have been passed around according to React lifecycle diagram:
from react-clamp-lines.
Regarding at the code, the only way I could see this happening is after a component unmount.
In the componentDidUnmount
, the listener is removed, but there could be a debounced call still on the event loop at this stage, that would be executed after the component is actually unmounted.
From react doc:
React will assign the current property with the DOM element when the component mounts, and assign it back to null when it unmounts. ref updates happen before componentDidMount or componentDidUpdate lifecycle methods.
from react-clamp-lines.
I don't have much time to test that assumption right now, but assuming it is, the fix would be to either:
- Ensure the component is still mounted before executing the
func.apply
in the debounced callback - Just check for this.element nullity in the clampLines function
from react-clamp-lines.
Thank you for your time and suggestion. This should be fixed now by
if (!this.element) return;
in clampLines()
from react-clamp-lines.
Related Issues (20)
- typescript definitions do not work with tsc version 3.3.3333 HOT 2
- ReferenceError: window is not defined in Next.js HOT 5
- Typescript definitions broken HOT 4
- Please unsubscribe from the rsize event in componentDidUnmount HOT 2
- Clamping doesn't work if the ClampLines element is inside a RelativePortal HOT 1
- Move the "more" button right after the ellipsis HOT 1
- aria-hidden="true" even when buttons are hidden HOT 2
- Not measuring line height again when the window has resived HOT 1
- clamping doesnt respect newlines HOT 1
- Typings / typescript
- HTML text rendering HOT 1
- Clamping doesn't work with the `word-break: break-all;` CSS property HOT 2
- add attribute aria-label for accessibility
- Package does not install with React 18 HOT 2
- Reset `noclamp` state to false when props text changes
- Bold on hover effect breaks past lines value.
- Support customization of overflow element HOT 1
- Test component with react testing-library
- Custom read-more buttons?
- Lines not working properly with React 18
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 react-clamp-lines.