Skip to content

Instantly share code, notes, and snippets.

@parshap
Last active August 29, 2015 14:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parshap/87dbfc0697769097dbd7 to your computer and use it in GitHub Desktop.
Save parshap/87dbfc0697769097dbd7 to your computer and use it in GitHub Desktop.
React container pattern
var React = require("react");
var TabbedComponent = React.createClass({
render: function() {
return TabsContainer({
tabs: [
// Pass instantiated component?
this.renderTab1(),
// Or pass function to create component?
this.renderTab1,
],
]);
},
renderTab1: function() {
return SomeTabContent({
someState: this.props.someState,
});
},
});
var TabsContainer = React.createClass({
// Handles state of which tab is "active"
// Shows active tab
// Provides UI to switch tabs
});
var SomeTabContent = React.createClass({
// Arbitrary component
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment