Last active
October 17, 2016 19:18
-
-
Save rhelmer/5bbebfd6ef60aea74804c6abf7f4d11c to your computer and use it in GitHub Desktop.
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
| "use strict"; | |
| Components.utils.import("resource://gre/modules/AddonManager.jsm"); | |
| const AddonBox = React.createClass({ | |
| getInitialState: function() { | |
| return {data: []}; | |
| }, | |
| componentDidMount: function() { | |
| AddonManager.getAddonsByTypes(["extension"], a => this.setState(a)); | |
| }, | |
| render: function() { | |
| return ( | |
| <div className="addonBox"> | |
| <AddonList data={this.state.data} /> | |
| </div> | |
| ); | |
| } | |
| }); | |
| const AddonList = React.createClass({ | |
| render: function() { | |
| console.log(this.props); | |
| let addonNodes = this.props.data.map(function(addon) { | |
| return ( | |
| <div className="addonList"> | |
| <Addon name={addon.name} version={addon.version} /> | |
| </div> | |
| ); | |
| }); | |
| return ( | |
| <div className="addonList"> | |
| {addonNodes} | |
| </div> | |
| ); | |
| } | |
| }); | |
| const Addon = React.createClass({ | |
| render: function() { | |
| return ( | |
| <div className="addon"> | |
| {this.props.name}, | |
| {this.props.version}, | |
| <button>enable/disable</button>, | |
| <button>uninstall</button>, | |
| </div> | |
| ); | |
| } | |
| }); | |
| ReactDOM.render( | |
| <AddonBox />, | |
| document.getElementById("content") | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment