Skip to content

Conversation

@jimfb
Copy link
Contributor

@jimfbjimfb commented Dec 3, 2014

Added findDOMNode, as we move toward deprecating getDOMNode

@syranide
Copy link
Contributor

I haven't followed any discussions, but this naming seems weird. find (vs get) seems like an implementation detail to me.

Nevermind me... or?

@jimfb
Copy link
ContributorAuthor

jimfb commented Dec 3, 2014

The bigger thing is that we're moving it off the component and into a static helper/utility function. That's the structural change, the name change is more of an "oh, while we're making the api change here, let's fix the name also, so users don't need to do two migrations"

I don't remember all the reasons we didn't like "get", but I think one of them might have been related to the fact that we may not have a 1-to-1 mapping from react components to dom nodes ([might be 1-to-0 today, might be extended to 1-to-n in future] - maybe I just made that up), and "get" has a connotation of being an instance method with a 1-to-1 mapping. Regardless, I know we were talking about "queryDOMNode" and "selectDOMNode", both of which were too easily confused with jquery selectors. Sema indicated we should go with "findDOMNode"

@zpao
Copy link
Member

zpao commented Dec 3, 2014

@syranide no, you didn't miss any explicit discussion. This is part of the decoupling that @sebmarkbage has been working on but some of the details haven't been well communicated. Specifically in this case, getDOMNode is already a thing mixed in only for DOM composite components and as we make the idea of components more generic, having this.getDOMNode available becomes riskier because the class might not be a DOM component class (eg it doesn't make any sense for a canvas rendered component to correlate to any DOM node). We can control it better at the top level instead of just having the engine throw undefined is not a function.

I'm not entirely happy with naming so we could probably bikeshed some more if you want. I'm personally leaning towards React.$():trollface:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll want a better message here. Also, we need to use printf format (with only %s), not string concat. invariant(condition, 'some %s string %s', 1, 2)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better?

@jimfbjimfbforce-pushed the getDOMNode-becomes-findDOMNode branch 3 times, most recently from e419094 to 414717cCompareDecember 4, 2014 01:33
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: false on new line

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@jimfbjimfbforce-pushed the getDOMNode-becomes-findDOMNode branch from 414717c to 1d55163CompareDecember 4, 2014 18:39
@jimfbjimfbforce-pushed the getDOMNode-becomes-findDOMNode branch 2 times, most recently from fe77ef8 to 0308e03CompareDecember 8, 2014 20:45
@sebmarkbage
Copy link
Collaborator

This should move into the browser folder since it's DOM specific.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you meant to check typeof componentOrElement.render === 'function', not the componentOrElement itself. Please add a unit test that covers this error message case.

@jimfbjimfbforce-pushed the getDOMNode-becomes-findDOMNode branch 3 times, most recently from 903f056 to 0810b08CompareDecember 18, 2014 21:39
@jimfbjimfbforce-pushed the getDOMNode-becomes-findDOMNode branch from 0810b08 to 8bbc60cCompareDecember 18, 2014 21:44
@sebmarkbage
Copy link
Collaborator

👍

jimfb added a commit that referenced this pull request Dec 22, 2014
Added findDOMNode, as we move toward deprecating getDOMNode
@jimfbjimfb merged commit e072534 into facebook:masterDec 22, 2014
@jimfbjimfb deleted the getDOMNode-becomes-findDOMNode branch December 22, 2014 21:05
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no %s so these won't be inserted anywhere.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent catch, thanks!

@jimfb
Copy link
ContributorAuthor

jimfb commented Jan 2, 2015

Updated diff: #2800

josephsavona pushed a commit that referenced this pull request May 15, 2024
Summary: Currently Forget bails on mutations to globals within any callback function. However, callbacks passed to useEffect should not bail and are not subject to the rules of react in the same way. We allow this by instead of immediately raising errors when we see illegal writes, storing the error as part of the function. When the function is called, or passed to a position that could call it during rendering, we bail as before; but if it's passed to `useEffect`, we don't raise the errors.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@jimfb@syranide@zpao@sebmarkbage