Files
webextensions-examples/react-es6-popup/src/popup.js
Maxim Zalata f369ddc642 convert chrome. to browser. Issue #165 #166 (#262)
* convert chrome. to browser. Issue #165

* fix browser-polyfill

* convert chrome.* to browser.* (#166)

* convert chrome.* to browser.*

* change chrome to browser

* change the callback-style to promise-style

* change the callback-style to promise-style
2017-09-11 15:23:41 -07:00

37 lines
807 B
JavaScript
Executable File

import React from 'react';
import ReactDOM from 'react-dom';
import Nested from './nested-component';
class Popup extends React.Component {
constructor(props) {
super(props);
this.state = {activeTab: null};
}
componentDidMount() {
// Get the active tab and store it in component state.
browser.tabs.query({active: true}).then(tabs => {
this.setState({activeTab: tabs[0]});
});
}
render() {
const {activeTab} = this.state;
return (
<div>
<h1>React Component</h1>
<p>
This is an example of a popup UI in React.
</p>
<p>
Active tab: {activeTab ? activeTab.url : '[waiting for result]'}
</p>
<Nested />
</div>
);
}
}
ReactDOM.render(<Popup/>, document.getElementById('app'));