For some reason, I\'m not able to use React.findDOMNode function. Browser complains about type error, saying React.findDOMNode is not a function. This is the code where this
The findDOMNode
method has moved from react
module to the react-dom
module.
So you have import or require the ReactDOM from react-dom
module then replace
var brand = React.findDOMNode(this.refs.brand).value.trim();
With
var ReactDOM = require('react-dom');
var brand = ReactDOM.findDOMNode(this.refs.brand).value.trim();
I would have commented on @romkyns answer but i don't have the rep.
So, I have been following a tutorial:
https://spring.io/blog/2015/09/15/react-js-and-spring-data-rest-part-2-hypermedia
By changing the content from the newest version of the project on github. There was an error both in the code that relates to the answer I also voted up, but realized there was a mistake.
So you must replace React.findDOMNode
by ReactDOM.findDOMNode
and not by deleting findDOMNode
as you stated.
I am not sure if this is due to a new version of Reactjs but this gave me the awaited result.
React.findDOMNode(component)
was introduced in React 0.13.0
as a replacement for component.getDOMNode()
.
Make sure that you have React 0.13.1
installed. If you're using npm, you can run npm view react version
to check which version of React is currently installed.
In React 15 (and possibly some earlier versions, I'm not sure) you don't need findDOMNode
to use refs at all:
this.refs.brand.value
is sufficient.