Preact: Support findDOMNode

Created on 13 Mar 2016  路  6Comments  路  Source: preactjs/preact

I have a use case where my components are given HTMLElements and I have to append them to the component. My usage is blocked because of this

See it on React Docs

Most helpful comment

Hi - Component#getDOMNode() and .findDOMNode() are both supported in preact-compat. Preact simply exposes your DOM Node as this.base within any component.

All 6 comments

Hi - Component#getDOMNode() and .findDOMNode() are both supported in preact-compat. Preact simply exposes your DOM Node as this.base within any component.

Wow, I looked into preact-markup and not in compat, sorry about that :bow:

No problem :) I am not against potentially adding a proper API for this (this.base is something I came up with and not supported by React), but I'd like to wait until things shake out a bit with React's API changes to see what they end up standardizing on. For reference, here's the implementation in preact-compat.
Cheers!

I don't really need anything else from preact-compat other than this method, are you going to keep compatibility in .base via semver? Is it okay to use it in my project?

It will work indefinitely, and yes a major version change would occur if it were changed in any way. I'm using .base in nearly all of my projects, you can definitely consider it a safe part of the API. Preact is very careful about exposing things, anything you have access to is part of the versions, public API.

Beautiful, Thank you for your awesome project :+1:

Was this page helpful?
0 / 5 - 0 ratings