From 0fbbf9f5af1772a20474debd2c56ecc70b6026ab Mon Sep 17 00:00:00 2001 From: Radwan Abu-Odeh Date: Sat, 13 Jan 2018 10:39:54 +0200 Subject: [PATCH] [HOTFIX] Fixed ReactBindings export. * [HOTFIX] R16N strucutre import * 1.0.2 * [HOTFIX] Changed how R16N exports React Bindings * 1.0.3 --- README.md | 12 +++++++++--- examples/react-example/app.jsx | 17 ++++++++--------- examples/react-example/package.json | 1 + package-lock.json | 2 +- package.json | 7 ++++--- src/index.js | 2 ++ 6 files changed, 25 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 4c37d31..cf1d16f 100644 --- a/README.md +++ b/README.md @@ -173,7 +173,9 @@ A binding for `getTranslation(state, key)` **example**: ```javascript -import {Translation} from 'r16n/React'; +import {ReactBindings} from 'r16n'; +const {Translation} = ReactBindings; + // ... Inside your component. // ... @@ -190,7 +192,9 @@ Whenever `setLocale(...)` action is called with new locale, it re-renders with t **example** : ```javascript -import {Date} from 'r16n/React' +import {ReactBindings} from 'r16n' +const {Date} = ReactBindings; + // ... Inside your component // en-> 2018-01-Tue 05:49PM, ar-> ٢٠١٨-٠١-ثلاثاء ٠٥:٤٩م // Different Formats for each locale. @@ -206,7 +210,9 @@ A binding for localizing numbers. **example** : ```javascript -import {Number} from 'r16n/React' +import {ReactBindings} from 'r16n' +const {Number} = ReactBindings; + // ... Inside your component // en-> 1, ar-> ١ // en-> 23,232 ar-> ٢٣٬٢٣٢ diff --git a/examples/react-example/app.jsx b/examples/react-example/app.jsx index 240a2a1..9362338 100644 --- a/examples/react-example/app.jsx +++ b/examples/react-example/app.jsx @@ -2,9 +2,8 @@ import React from 'react'; import ReactDom from 'react-dom'; import { combineReducers, createStore, compose } from 'redux'; import { connect, Provider } from 'react-redux'; -import {createR16nReducer, setLocale, getLocale, getTranslation} from '../../dist'; -import {Number, Date} from '../../dist/React'; -const Translation = require('../../dist/React').Translation; +import { createR16nReducer, setLocale, getLocale, getTranslation, ReactBindings } from 'r16n'; +const { Translation, Number, Date } = ReactBindings; const locales = { en: { @@ -48,7 +47,7 @@ const App = ({ text, locale, setLocale, r16nStore, dummyText }) => - +

{locale} -> {text}

@@ -58,14 +57,14 @@ const App = ({ text, locale, setLocale, r16nStore, dummyText }) =>

Translation

-
+

Numbers

-
+

Dates

-
- -
+
+ +

Store Structure

diff --git a/examples/react-example/package.json b/examples/react-example/package.json
index c86cbdf..7e86ee6 100644
--- a/examples/react-example/package.json
+++ b/examples/react-example/package.json
@@ -9,6 +9,7 @@
   "author": "",
   "license": "ISC",
   "dependencies": {
+    "r16n": "^1.0.3",
     "react": "^16.2.0",
     "react-dom": "^16.2.0",
     "react-redux": "^5.0.6",
diff --git a/package-lock.json b/package-lock.json
index d7fbdec..24327e2 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
 {
   "name": "r16n",
-  "version": "1.0.1",
+  "version": "1.0.3",
   "lockfileVersion": 1,
   "requires": true,
   "dependencies": {
diff --git a/package.json b/package.json
index cbf8fcb..f9b9cef 100644
--- a/package.json
+++ b/package.json
@@ -1,8 +1,8 @@
 {
   "name": "r16n",
-  "version": "1.0.1",
+  "version": "1.0.3",
   "description": "Redux internationalization. This library provides Redux reducer to translate strings, and React components to localize dates, and numbers.",
-  "main": "dist/index.js",
+  "main": "dist",
   "files": [
     "dist",
     "examples"
@@ -12,7 +12,8 @@
     "test:lint": "eslint src",
     "build": "babel src -d dist",
     "build:watch": "npm run build -- --watch",
-    "clean": "rimraf dist"
+    "clean": "rimraf dist",
+    "prepublish": "npm run build"
   },
   "repository": {
     "type": "git",
diff --git a/src/index.js b/src/index.js
index f821d9d..2364690 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,3 +1,5 @@
+import * as ReactBindings from './React';
 export { createR16nReducer } from './store_elements/reducer';
 export { setLocale } from './store_elements/actions';
 export { getTranslation, getLocale, getTranslations } from './store_elements/selectors';
+export {ReactBindings};