Skip to content

Commit

Permalink
React Library improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
berkaytheunicorn committed Feb 6, 2019
1 parent f063fed commit a9b1ad9
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "world-i18n",
"version": "1.0.1",
"version": "1.0.5",
"description": "Lightweight internationalization library for JS.",
"react": {
"main": "lib/react/index.js",
Expand Down
1 change: 1 addition & 0 deletions src/World.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class World {
}

createContext(locale) {
// eslint-disable-next-line
return new Promise(resolve => {
this.setLocale(locale, () => {
resolve({
Expand Down
5 changes: 3 additions & 2 deletions src/react/Context.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from "react";
const Context = React.createContext();

export const WorldConsumer = Context.Consumer;
const WorldContext = React.createContext();

export default WorldContext;
2 changes: 1 addition & 1 deletion src/react/Provider.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from "react";

import Context from "./Context";
class WorldProvider extends Component {
constructor(props) {
super(props);
Expand Down
2 changes: 1 addition & 1 deletion src/react/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
withWorld: require("./withWorld"),
WorldProvider: require("./Provider"),
WorldConsumer: require("./Context")
WorldContext: require("./Context")
};
6 changes: 3 additions & 3 deletions src/react/withWorld.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from "react";

import displayName from "./displayName";
import { WorldConsumer } from "./Context";
import Context from "./Context";

const withWorld = options => {
return ComposedComponent => {
Expand All @@ -10,7 +10,7 @@ const withWorld = options => {
class C extends Component {
render() {
return (
<WorldConsumer>
<Context.Consumer>
{({ world }) => {
return (
<ComposedComponent
Expand All @@ -21,7 +21,7 @@ const withWorld = options => {
/>
);
}}
</WorldConsumer>
</Context.Consumer>
);
}
}
Expand Down

0 comments on commit a9b1ad9

Please sign in to comment.