Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React: 🐛 Fix init to be optional #2828

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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