-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
52 changed files
with
10,727 additions
and
1,887 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
## Util Functions | ||
|
||
We provides util functions for you to easily access the resource provided by `react-i13n`, you have two options to get the util functions, | ||
|
||
- `props` - When you are using [setupI13n](../api/setupI13n.md) or [createI13nNode](../api/createI13nNode.md), we will pass util functions via `this.props.i13n`. Please note that starts from `2.3.0`, you can pass `skipUtilFunctionsByProps=true` to prevent `props.i13n` being passed to fix the unknown props warning from `[email protected]`. | ||
- `context` - You can always define `contextTypes` and access util functions via `context`, i.e., `this.context.i13n`. | ||
We provides util functions for you to easily access the resource provided by `react-i13n`, you can get util function via | ||
// @TODO, update use react context | ||
`props` - When you are using [setupI13n](../api/setupI13n.md) or [createI13nNode](../api/createI13nNode.md), we will pass util functions via `this.props.i13n`. Please note that starts from `2.3.0`, you can pass `skipUtilFunctionsByProps=true` to prevent `props.i13n` being passed to fix the unknown props warning from `[email protected]`. | ||
|
||
```js | ||
// with setupI13n or createI13nNode, you will automatically get this.props.i13n for i13n util functions | ||
|
@@ -13,19 +12,18 @@ class DemoComponent extends React.Component { | |
// this.props.i13n.getI13nNode() to access the i13nNode created by createI13nNode | ||
// this.props.i13n.executeEvent() to execute i13n event | ||
} | ||
}; | ||
} | ||
|
||
const I13nDemoComponent = createI13nNode(DemoComponent); | ||
``` | ||
|
||
```js | ||
|
||
// For components without `setupI13n` and `createI13nNode`, you can still get i13n functions via context | ||
import { I13nContext } from 'react-i13n'; | ||
class DemoComponent extends React.Component { | ||
displayName = 'DemoComponent',; | ||
contextTypes = { | ||
i13n: React.PropTypes.object | ||
}; | ||
static contextType = I13nContext; | ||
render() { | ||
// this.context.i13n.getI13nNode() to access the nearest i13nNode created by createI13nNode | ||
// this.context.i13n.executeEvent() to execute i13n event | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// polyfill | ||
require('intersection-observer'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
module.exports = { | ||
setupFilesAfterEnv: ['./jest-setup.js'], | ||
reporters: ['default', 'jest-junit'] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.