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

Set ready flag to false when i18n instance has not been initialised #918

Merged
merged 1 commit into from
Aug 12, 2019

Conversation

nickythorne
Copy link

No description provided.

@jamuhl
Copy link
Member

jamuhl commented Aug 12, 2019

Does this make a difference? I mean this is an issue in code and I hope your app never ships with this problem of not having passed an i18n instance down there? So you get the warning anyway...ready: true|false makes no difference in this case...the userland code is broken when getting there.

@nickythorne
Copy link
Author

nickythorne commented Aug 12, 2019

Setting ready to false for this particular code flow (when i18n is not initialised) just makes sense. But I believe there is also a genuine use case for such behaviour... If the initialisation of the i18n instance is deferred (the reason for which is irrelevant), relying on the correctness of this flag could be quite useful to enable client applications to display some alternative component before it is initialised, for example, displaying placeholders.

An example:

const Header: React.FC = () => {

    const { t, ready } = useTranslation();

    return (
        <Container>
            <Placeholder ready={ready}>
                <Title>{t("header.title")}</Title>
                <SubTitle>{t("header.subtitle")}</SubTitle>
            </Placeholder>
        </Container>
    )
};

@jamuhl jamuhl merged commit 2c63194 into i18next:master Aug 12, 2019
@jamuhl
Copy link
Member

jamuhl commented Aug 12, 2019

published in react-i18next@10.12.1

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

Successfully merging this pull request may close these issues.

3 participants