mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-17 06:48:37 +02:00
* 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
37 lines
807 B
JavaScript
Executable File
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'));
|