-
Notifications
You must be signed in to change notification settings - Fork 414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible removal of findDOMNode()
from React in a future version
#251
Comments
findDOMNode()
from ReactfindDOMNode()
from React in a future version
This is making me uneasy... I'm a heavy user of |
To be clear React still provides a way to get the node: with callback refs. I’m not sure how that would translate to your API but jsx-eslint/eslint-plugin-react#678 has some React examples for better alternative patterns. |
@Frozenlock, its actually pretty straight forward to get the actual dom element as @gaearon mentions. I'll post a very simple example of this in reagent. |
This example illustrates how to avoid using React's (defn hello-component
[]
(let [dom-node (atom nil)]
(reagent/create-class
{:component-did-mount (fn [x] (js/console.log @dom-node))
:reagent-render (fn [x] [:h2 {:ref (fn [y] (reset! dom-node y))} "hello"])}))) Note: dom-node is a clojurescript atom and not a reagent atom. Repo with this code is here. Edit: I've removed |
Wow that is easy AND straight forward... |
Looks simple enough. I wasn't aware of the |
Regarding
More here. So basically, you can place any function in Hope this makes sense. |
It does. If I understand correctly, it's a much simpler Also, it appears that the unmounting function in the example is superfluous:
|
@Frozenlock, that's true. I didn't realise that. I'll fix my example |
Is there an alternative for ReactDOM.findDOMNode (this.element).getClientBoundingRect ()? |
What is |
I think Let's say I want to create a I would use it like this: <HashAnchor id="something">
<AnyComponent />
</HashAnchor> I can't use I think this is exactly the case where "findDOMNode escape hatch" use is justified. One still could argue that So we can just wrap the child with a I would use it like this: <HashAnchor id="something">
<div id="something">
<AnyComponent />
</div>
</HashAnchor> |
|
@bskimball if You need findDOMNode only when all you have is a reference to a component instance. |
I'm sorry I misrepresented |
@everdimension AFAIK Most React components support |
@Deraen not "most", but "stateful" components support |
Tagging as wontfix, as this doesn't seem to be needed in near future. The function is still available and not deprecated in React 16. If we at some point change Reagent to generate functional components, we would need to revisit this as |
Related #490 |
There are rumblings in the React world of deprecating
findDOMNode()
which is equivalent to Reagent'sreagent.core/dom-node
.@gaearon also tweeted about it here.
We may want to start planning for this in a future release.
The text was updated successfully, but these errors were encountered: