Lang.js 755 Bytes
Newer Older
qianyuheng committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
import React,{Component} from 'react'
import { inject, observer } from 'mobx-react'



@inject('i18n')
@inject('UserContext')
@observer
export default class Lang extends Component{
    componentWillMount()
    {
        this.props.i18n.lang = this.props.lang == 'cn'? 'cn' : 'en'
        this.props.i18n.langInit = true
    }

    componentWillReceiveProps(nextProps)
    {
        // this.props.i18n.lang = nextProps.lang == 'cn'? 'cn' : 'en'
        // this.props.i18n.langInit = true

        if(this.props.i18n.lang != nextProps.lang)
        {
            window.location.reload()
        }
    }

    render(){
       
        return <React.Fragment>
            {
                this.props.children
            }
        </React.Fragment>
    }
}