precharts icon indicating copy to clipboard operation
precharts copied to clipboard

Cannot read property 'parentElement' of undefined - Errors with [email protected]

Open rubencodes opened this issue 8 years ago • 2 comments
trafficstars

I've been having some issues using this with the latest Preact; I was getting similar warnings on 7.x but now it's flat-out not working.

screen shot 2017-04-17 at 10 54 49 pm screen shot 2017-04-17 at 10 55 28 pm

At the risk of providing a red-herring: I have a branch of my project that uses preact-router instead of react-router, and it seems to work just fine there? Not sure what gives...

rubencodes avatar Apr 18 '17 06:04 rubencodes

The preact-router swap is an interesting data point. Maybe something is being removed immediately after state is being mutated on it?

If this.container is a ref, perhaps in prior versions of preact were re-calling the ref with a different element from a new route, and that is no longer happening in 8? If so, we could just change the ref handling to ignore null values:

containerRef = el => {
  if (el!=null) this.container = el;
};

Not the best for memory, but it would mean the ref is still around during unmounts.

developit avatar Apr 18 '17 12:04 developit

Oh, thanks pal

Arkady-Skvortsov avatar Aug 24 '19 18:08 Arkady-Skvortsov