Skip to content

Commit ff797d6

Browse files
authored
Merge pull request #6 from samuelcastro/shared-client
Creating shared clients passing the config key.
2 parents f48c23e + 1f90a99 commit ff797d6

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,5 +203,4 @@ Update local custom node modules packages
203203
## TODO
204204

205205
- Unit tests
206-
- Use React Hooks rather than class components.
207206
- Integrate [Semantic Release](https://semantic-release.gitbook.io/semantic-release/) to automate the releasing process.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-splitio",
3-
"version": "0.1.7",
3+
"version": "0.1.8-beta.1",
44
"author": {
55
"name": "Samuel Castro",
66
"email": "samuelcastrosilva@gmail.com",

src/SplitProvider.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,22 @@ const SplitProvider = ({
7070
setUpdated({ isReady: false, lastUpdate: 0 });
7171
}
7272

73-
/** @link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#2-instantiate-the-sdk-and-create-a-new-split-client */
74-
const nextClient = SplitFactory({
73+
const sdkConfig: SplitIO.IBrowserSettings = {
7574
...config,
75+
76+
/** @link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#2-instantiate-the-sdk-and-create-a-new-split-client */
7677
impressionListener: {
7778
logImpression: handleImpression,
7879
},
79-
}).client();
80+
};
81+
82+
/**
83+
* Instantiating a new factory
84+
* @link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK
85+
*/
86+
const factory: SplitIO.ISDK = SplitFactory(sdkConfig);
87+
const nextClient = factory.client(config.core.key, config.core.trafficType);
88+
8089
setClient(nextClient);
8190

8291
// Only make state changes if component is mounted.

0 commit comments

Comments
 (0)