The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Write More Reusable React Components with Composable APIs

Write More Reusable React Components with Composable APIs

4:41
To make more composable React components, you can define common APIs for similar component types.
Watch this lesson now
Avatar
egghead.io

To make more composable React components, you can define common APIs for similar component types.

Avatar
BloomBoard

Hi Joe not sure if this is the best forum for this type of question so please point me to the place if it isn't.

What sublime package are you using for your typeahead and other react snippets?

Great video series so far!

Bryce

In reply to egghead.io
Avatar
Dean

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.

Avatar
Joseph

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.

var App = react.createClass({
method: function(){
return this.refs.comp.method();
},
render: function(){
return <InheritFromThisComponent ref="comp" />
}
})

In reply to Dean
Avatar
Faria

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?

Avatar
leonardo

Inhale and exhale, you are teaching man!

Avatar
Abhishek

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

Avatar
Joseph

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.

In reply to Abhishek
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?