UNPKG

create-chrome-ext

Version:

Scaffolding your chrome extension, multiple boilerplates supported!

41 lines (33 loc) 836 B
import { Component } from 'inferno' import './Options.css' export class Options extends Component { link = 'https://github.com/guocaoyi/create-chrome-ext' constructor(props) { super(props) this.state = { countSync: 0, } } componentDidMount() { chrome.storage.sync.get(['count'], (result) => { this.setState({ countSync: result.count || 0 }) }) chrome.runtime.onMessage.addListener((request) => { if (request.type === 'COUNT') { this.setState({ countSync: request.count || 0 }) } }) } render() { return ( <main> <h3>Options Page</h3> <h4>Count from Popup: {this.state.countSync}</h4> <a href={this.link} target="_blank"> generated by create-chrome-ext </a> </main> ) } } export default Options