Assembless / react-littera

🌐 Modern react library for managing translations.
MIT License
19 stars 1 forks source link

🎉 Stable release (2.0.0) #7

Closed DRFR0ST closed 4 years ago

DRFR0ST commented 4 years ago

Changelog

All notable changes for this version.

Added

Changed

Migration 1.X => 2.X

The migration process is straightforward. You have to rename some properties and change the way you use useLittera.

Changed naming

Mainly pay attention to LitteraProvider and withLittera props naming.

LitteraProvider changes

The provider accepts 2 new props locales: string[] and initialLocale?: string. You don't need to use your own state from now, the provider will handle it by itself. That makes the locale and setLocale props not required.

// v1.X
const [language, setLanguage] = useState("en_US");

return <LitteraProvider language={language} setLanguage={setLanguage}>
   {children}
</LitteraProvider>

// v2.X
return <LitteraProvider locales={["en_US", "de_DE", "pl_PL"]}>
   {children}
</LitteraProvider>

useLittera changes

The hook returns only the translated object now. Use useLitteraMethods to get/set locale, set pattern etc.

// v1.X
const [translated, locale, setLanguage] = useLittera(translated)

// v2.X
const translated = useLittera(translated);
const { locale, setLocale, pattern, setPattern, validateLocale } = useLitteraMethods();
ghost commented 4 years ago

Congratulations :tada:. DeepCode analyzed your code in 2.672 seconds and we found no issues. Enjoy a moment of no bugs :sunny:.

👉 View analysis in DeepCode’s Dashboard | Configure the bot