To make more composable React components, you can define common APIs for similar component types.
Hey - What would you suggest that if we wanted to reuse "NumInput" but "add" some additional props or whatever, is there a way to "extend" it. Because we might want to use NumInput , but might need something additional so its usage isn't so particular.
There's no clear method in React for extending an existing component, but mixins are a great place to start.
You could also wrap the component you want to inherit from and call it's methods using a ref.
<code> var App = react.createClass({ method: function(){ return this.refs.comp.method(); }, render: function(){ return <InheritFromThisComponent ref="comp" /> } }) </code>In your example, the input is an uncontrolled component because you use defaultvalue, instead of a value, is that correct? Does the code need to be changed if I make it a controlled component instead?
Inhale and exhale, you are teaching man!
I am using React version 0.14.0 on a Mac OSX
When I type this code in, it is functional and I am getting an error of "Uncaught TypeError: React.findDOMNode is not a function"
I understand React.findDOMNode is introduced in the 0.13.0 release of React. Why is this error being thrown? Did it get deprecated in 0.14.0?
Thanks
In React v0.14 some methods like findDOMNode have been moved to a separate package.
Include https://fb.me/react-dom-0.14.0.js in your application and use ReactDOM.findDOMNode, ReactDOM.render, and ReactDOM. unmountComponentAtNode where applicable.
Hi Joe,In the beginning of this lecture you have mentioned that you have created all the input range components using refs in a separate lecture,I am unable to find the lecture in this series.If possible can you please provide me a link to that lecture.
Thanks
Same here. And there is nothing in the course repo either. Thanks!
Hi Mitesh, even though I didn't find the original code for the various inputs, I did manage to get the code that we start with here to work. When I push it to github, I will share the link here. Perhaps this will help?
Mitesh (and anyone else who is interested), here is the link of the commit containing the original code re various inputs/input refs: https://github.com/interglobalmedia/react-basics/commit/ab93964c44e393cc11e98584915ac79b6e39f85f Hope this helps!