Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RNLocalize .addEventListener on change method is calling even on the network change #59

Closed
PitlaSpandana opened this issue Jul 26, 2019 · 2 comments

Comments

@PitlaSpandana
Copy link

RNLocalize.addEventListener("change", () => {
// do localization related stuff…
});

the above method is calling even on network switching from one to another. can anyone help me out how to fix this issue

@zoontek
Copy link
Owner

zoontek commented Jul 26, 2019

@PitlaSpandana Please respect the issue template. On which platforms? Which version?

@PitlaSpandana
Copy link
Author

PitlaSpandana commented Jul 26, 2019

@PitlaSpandana Please respect the issue template. On which platforms? Which version?

I was testing in Android tablet OS version 8.0.0(samsung galaxy tab s3). and using
react-native-localize: "^1.1.2". below is my index.android.js file

import React, { Component } from 'react';
import {
  StyleSheet,
} from 'react-native';
import * as RNLocalize from "react-native-localize";

export default class Test extends Component {
  constructor(props) {
    super(props);
  }

  componentDidMount() {
    RNLocalize.addEventListener('change', this.handleLocaleChange);
  }

  handleLocaleChange = () => {
    console.log('***************', RNLocalize.getLocales());
  }

  componentWillUnmount() {
    RNLocalize.removeEventListener('change', this.handleLocaleChange);
  }

  render() {
    return (
      <AppContainer>
      </AppContainer>
    );
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants