Skip to content

AdamRamberg/fbt-easy-setup

Repository files navigation

fbt-easy-setup

Utilities to get you started using fbt in your app.

Demo

Checkout the demo app: https://adamramberg.github.io/fbt-easy-setup/

The source could be found here.

Prerequisites

fbt-easy-setup the following dependencies to be installed:

fbt >=0.9.0
react >=16.8.0

Installation

Using yarn:


yarn add fbt-easy-setup --save

Using npm:


npm install fbt-easy-setup --save

API

init

init is an enhanced version of fbt's init function. Call the init function before you mount the app, eg. using webpack's entry option. See example.

Parameters

translations Your apps translations in the output format of fbt's /babel-plugin-fbt/bin/translate.js.

locales Locales in the same format as in fbt's demo app, eg:

en_US: {
  bcp47: 'en-US',
  displayName: 'English (US)\u200e',
  englishName: 'English (US)',
  rtl: false,
}

defaultLocale Default locale set if not found in storage. Format should be the same format as keys in the locales sent in.

storage - optional By default fbt-easy-setup is using local storage. Send in your own storage (following the local storage API). This might be useful in order to implement SSR.

LocaleProvider

Wrap your application with this Provider. See example.

Parameters

rerender - optional

By default the app is rerendered using window.location.reload() when the locale changes. Set your own rerender logic using the rerender prop.

LocaleConsumer

Get the current locale and a locale setter function (setLocale) using this context Consumer. See example.

About

Utilities that makes it easy to start using fbt

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published