Skip to content

Commit

Permalink
➖ React: Remove extra pro specific setup (#2929)
Browse files Browse the repository at this point in the history
* ➖ React: Remove extra pro specific setup

* ⬆ Update package deps for vitest
  • Loading branch information
chuckcarpenter authored Jul 25, 2024
1 parent 869857f commit 04ff0ff
Show file tree
Hide file tree
Showing 5 changed files with 9,342 additions and 7,422 deletions.
2 changes: 1 addition & 1 deletion packages/pro-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"test:dev": "vitest"
},
"devDependencies": {
"@vitest/ui": "^1.6.0",
"@vitest/ui": "^2.0.4",
"fake-indexeddb": "^6.0.0",
"jsdom": "^24.1.0",
"vite": "^5.3.2",
Expand Down
3 changes: 1 addition & 2 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@
"test:dev": "vitest"
},
"dependencies": {
"@shepherdpro/pro-js": "workspace:*",
"shepherd.js": "workspace:*"
},
"devDependencies": {
"@testing-library/jest-dom": "^6.2.0",
"@testing-library/react": "^16.0.0",
"@types/react": "^18.3.3",
"@vitejs/plugin-react": "^4.2.1",
"@vitest/ui": "^1.6.0",
"@vitest/ui": "^2.0.4",
"happy-dom": "^14.11.0",
"typescript": "^5.4.5",
"vite": "^5.3.2",
Expand Down
30 changes: 6 additions & 24 deletions packages/react/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
import { createContext, FC, useContext, type ReactNode } from 'react';

import Shepherd from 'shepherd.js';
import ShepherdPro from '@shepherdpro/pro-js';

interface ShepherdProviderProps {
apiKey?: string;
apiPath?: string;
properties?: Record<string, unknown>;
children?: ReactNode;
}

interface ShepherdContextType {
Shepherd: typeof ShepherdPro | typeof Shepherd;
Shepherd: typeof Shepherd;
}

const ShepherdJourneyContext = createContext<ShepherdContextType | undefined>(
Expand All @@ -32,22 +23,13 @@ export const useShepherd = () => {
return ShepherdInsance;
};

export const ShepherdJourneyProvider: FC<ShepherdProviderProps> = ({
apiKey,
apiPath,
properties,
export const ShepherdJourneyProvider = ({
children
}: ShepherdProviderProps) => {
let JourneyLibrary = Shepherd;
if (typeof window !== 'undefined') {
if (apiKey) {
JourneyLibrary = ShepherdPro;
ShepherdPro.init(apiKey, apiPath, properties);
}
}

}: {
children?: ReactNode;
}) => {
return (
<ShepherdJourneyContext.Provider value={{ Shepherd: JourneyLibrary }}>
<ShepherdJourneyContext.Provider value={{ Shepherd }}>
{children}
</ShepherdJourneyContext.Provider>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/react/test/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('<ShepherdTour />', () => {
);
};
const TestApp = () => (
<ShepherdJourneyProvider apiKey={'sh_thisIsAnAmazingKey123'}>
<ShepherdJourneyProvider>
<Button />
</ShepherdJourneyProvider>
);
Expand Down
Loading

0 comments on commit 04ff0ff

Please sign in to comment.