React-Intl how to switch locale and messages from variable

后端 未结 3 525
Happy的楠姐
Happy的楠姐 2021-02-04 06:28

I\'m trying to figure out how to change language using React-Intl. This is my first React App and it has been made with create-react-app, I\'m not using Redux nor Flux.

3条回答
  •  悲哀的现实
    2021-02-04 07:01

    you can use redux manage your locale and localeMessage. just add a key in IntlProvider.

    import React, { Component } from 'react';
    import { IntlProvider } from 'react-intl';
    
    class Inter extends Component {
        render() {
          let { locale, localeMessage, children } = this.props;
          return (
              
                  {children}
              
          )
        }
    };
    
    export default Inter;

提交回复
热议问题