import React, { Component } from 'react';
import PropTypes from 'prop-types'

class Web3Provider extends Component {
  render() {
    if (window.web3) {
      return this.props.children
    }

    return <this.props.web3UnavailableScreen />
  }

  getChildContext() {
    return {
      web3: window.web3
    }
  }
}

Web3Provider.childContextTypes = {
  web3: PropTypes.object
}

export default Web3Provider;

@@ -33,17 +33,16 @@
  'react'
-;
 %0Aimport 
@@ -73,235 +73,1554 @@
 es'%0A
-%0Aclass Web3Provider extends Component %7B%0A  render() %7B%0A    if (window.web3) %7B%0A      return this.props.children%0A    %7D%0A%0A    return %3Cthis.props.web3UnavailableScreen /%3E%0A  %7D%0A%0A  getChildContext() %7B%0A    return %7B%0A      web3: window.web3
+import Web3 from 'web3'%0A%0Aconst ONE_SECOND = 1000;%0A%0Aclass Web3Provider extends Component %7B%0A  constructor(props, context) %7B%0A    super(props, context)%0A%0A    this.state = %7B%0A      selectedAccount: null%0A    %7D%0A%0A    this.web3 = null%0A    this.interval = null%0A%0A  %7D%0A  render() %7B%0A    const %7B web3UnavailableScreen: Web3UnavailableScreen %7D = this.props%0A%0A    if (window.web3) %7B%0A      if (!this.web3) %7B%0A        this.web3 = new Web3(window.web3.currentProvider);%0A        this.fetchAccounts()%0A      %7D%0A%0A      return this.props.children%0A    %7D%0A%0A    return %3CWeb3UnavailableScreen /%3E%0A  %7D%0A%0A  componentDidMount() %7B%0A    this.initPoll();%0A  %7D%0A%0A  initPoll = () =%3E %7B%0A    if (!this.interval) %7B%0A      this.interval = setInterval(this.fetchAccounts, ONE_SECOND)%0A    %7D%0A  %7D%0A%0A  fetchAccounts = () =%3E %7B%0A    const %7B web3  %7D = this%0A    const %7B onChangeAccount %7D = this.props%0A%0A    if (!web3 %7C%7C !web3.eth) %7B%0A      return%0A    %7D%0A%0A    return web3.eth.getAccounts()%0A      .then(accounts =%3E %7B%0A        if (!accounts %7C%7C !accounts.length) %7B%0A          return%0A        %7D%0A%0A        let curr = this.state.selectedAccount%0A        let next = accounts%5B0%5D%0A        curr = curr && curr.toLowerCase()%0A        next = next && next.toLowerCase()%0A%0A        const didChange = curr && next && (curr !== next)%0A%0A        if (didChange && typeof onChangeAccount === 'function') %7B%0A          onChangeAccount(next)%0A        %7D%0A%0A        this.setState(%7B%0A          selectedAccount: next %7C%7C null%0A        %7D)%0A      %7D)%0A  %7D%0A%0A  getChildContext() %7B%0A    return %7B%0A      web3: this.web3,%0A      selectedAccount: this.state.selectedAccount
 %0A   
@@ -1688,16 +1688,53 @@
 s.object
+,%0A  selectedAccount: PropTypes.string
 %0A%7D%0A%0Aexpo

Add onChangeAccount callback and selectedAccount context variable