Skip to content

Commit

Permalink
React: 🐛 Fix init to be optional (#2828)
Browse files Browse the repository at this point in the history
  • Loading branch information
chuckcarpenter authored May 24, 2024
1 parent 6c5e3a2 commit 488c18a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions packages/react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ that can be passed into props for dynamic interactivity.
Use this simple NPM command or whatever package manager is your favorite.

```bash
npm install --save @shepherdpro/react
npm install --save react-shepherd
```

## Usage
Expand All @@ -33,8 +33,8 @@ const tourOptions = {
};

function Button() {
const shepherd = useShepherd(ShepherdTourContext);
const tour = shepherd.Tour({
const Shepherd = useShepherd();
const tour = new Shepherd.Tour({
...tourOptions,
steps: newSteps
});
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Shepherd from 'shepherd.js';
import type ShepherdPro from 'shepherd.js';

interface ShepherdProviderProps {
apiKey: string;
apiKey?: string;
apiPath?: string;
properties?: Record<string, unknown>;
children?: ReactNode;
Expand Down Expand Up @@ -39,7 +39,7 @@ export const ShepherdJourneyProvider: FC<ShepherdProviderProps> = ({
children
}: ShepherdProviderProps) => {
if (typeof window !== 'undefined') {
Shepherd.init(apiKey, apiPath, properties);
if (apiKey) Shepherd.init(apiKey, apiPath, properties);
}

return (
Expand Down

0 comments on commit 488c18a

Please sign in to comment.