Last active
August 29, 2015 14:04
-
-
Save parshap/87dbfc0697769097dbd7 to your computer and use it in GitHub Desktop.
React container pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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