diff --git a/example-rn/.gitignore b/example-rn/.gitignore
index ad572e6..be61c97 100644
--- a/example-rn/.gitignore
+++ b/example-rn/.gitignore
@@ -21,6 +21,8 @@ DerivedData
*.ipa
*.xcuserstate
+use-pusher
+
# Android/IntelliJ
#
build/
diff --git a/example-rn/App.js b/example-rn/App.js
index adb1b57..50138d0 100644
--- a/example-rn/App.js
+++ b/example-rn/App.js
@@ -28,11 +28,7 @@ const config = {
import {PusherProvider} from '@harelpls/use-pusher/react-native';
const App = () => {
- return (
-
-
-
- );
+ return ;
};
const Screen = () => {
diff --git a/rollup.config.js b/rollup.config.js
index a73a945..bbde27e 100644
--- a/rollup.config.js
+++ b/rollup.config.js
@@ -62,6 +62,12 @@ export default [
exports: "named",
sourcemap: true,
},
+ {
+ file: "example-rn/use-pusher/index.js",
+ format: "cjs",
+ exports: "named",
+ sourcemap: true,
+ },
],
},
];
diff --git a/src/PusherProvider.tsx b/src/PusherProvider.tsx
index 77b5c50..86c4867 100644
--- a/src/PusherProvider.tsx
+++ b/src/PusherProvider.tsx
@@ -1,4 +1,4 @@
-import Pusher, { Options } from "pusher-js";
+import { Options } from "pusher-js";
import { PusherContextValues, PusherProviderProps } from "./types";
import React, { useEffect, useRef, useState } from "react";
@@ -15,13 +15,13 @@ export const __PusherContext = PusherContext;
* @param props Config for Pusher client
*/
-export const PusherProvider: React.FC = ({
+export const CorePusherProvider: React.FC = ({
clientKey,
cluster,
triggerEndpoint,
defer = false,
children,
- _PusherRuntime = Pusher,
+ _PusherRuntime,
...props
}) => {
// errors when required props are not passed.
@@ -37,11 +37,12 @@ export const PusherProvider: React.FC = ({
useEffect(() => {
previousConfig.current = props;
});
- const [client, setClient] = useState();
+ const [client, setClient] = useState();
useEffect(() => {
// Skip creation of client if deferring, a value prop is passed, or config props are the same.
if (
+ !_PusherRuntime ||
defer ||
props.value ||
(dequal(previousConfig.current, props) && client !== undefined)
diff --git a/src/PusherProviderWeb.tsx b/src/PusherProviderWeb.tsx
new file mode 100644
index 0000000..b1393ac
--- /dev/null
+++ b/src/PusherProviderWeb.tsx
@@ -0,0 +1,9 @@
+import React from "react";
+import Pusher from "pusher-js/react-native";
+import { CorePusherProvider } from "./PusherProvider";
+import { PusherProviderProps } from "./types";
+
+/** Wrapper around the core PusherProvider that passes in the Pusher react-native lib */
+export const PusherProvider: React.FC = (props) => (
+
+);
diff --git a/src/__tests__/PusherProvider.test.tsx b/src/__tests__/PusherProvider.test.tsx
index 608999c..8319914 100644
--- a/src/__tests__/PusherProvider.test.tsx
+++ b/src/__tests__/PusherProvider.test.tsx
@@ -7,7 +7,7 @@ const Pusher = require(process.env.JEST_ENV === "rn"
const { PusherProvider } = require(process.env.JEST_ENV === "rn"
? "../react-native/PusherProvider"
- : "../PusherProvider");
+ : "../PusherProviderWeb");
const { render } = require(process.env.JEST_ENV === "rn"
? "@testing-library/react-native"
diff --git a/src/index.ts b/src/index.ts
index 9ded415..bf9604f 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,5 +1,6 @@
// hooks for prod
export * from "./PusherProvider";
+export * from "./PusherProviderWeb";
export * from "./usePusher";
export * from "./useChannel";
export * from "./usePresenceChannel";