Skip to content

Commit b948967

Browse files
committed
Fix type error in walkthroughable
1 parent b67bf9c commit b948967

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

README.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,21 @@ By default, if overlay is not explicitly specified, the `svg` overlay will be us
141141
You can customize the tooltip and the step number components by passing a component to the `CopilotProvider` component. If you are looking for an example tooltip component, take a look at [the default ui implementations](https://github.com/mohebifar/react-native-copilot/blob/master/src/components/default-ui).
142142

143143
```js
144-
const TooltipComponent = ({
145-
isFirstStep,
146-
isLastStep,
147-
handleNext,
148-
handleNth,
149-
handlePrev,
150-
handleStop,
151-
currentStep,
152-
}) => (
153-
// ...
154-
);
144+
const TooltipComponent = () => {
145+
const {
146+
isFirstStep,
147+
isLastStep,
148+
handleNext,
149+
handleNth,
150+
handlePrev,
151+
handleStop,
152+
currentStep,
153+
} = useCopilot();
154+
155+
return (
156+
// ...
157+
)
158+
};
155159

156160

157161
<CopilotProvider tooltipComponent={TooltipComponent} stepNumberComponent={StepComponent}>

src/hocs/walkthroughable.tsx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
import React, { type FunctionComponent } from "react";
22
import { type NativeMethods } from "react-native/types";
33

4-
type PropsWithCopilot<P> = P & {
5-
copilot: {
6-
ref?: React.RefObject<NativeMethods>;
7-
onLayout?: () => void;
8-
};
9-
};
4+
interface CopilotType {
5+
ref?: React.RefObject<NativeMethods>;
6+
onLayout?: () => void;
7+
}
108

119
export function walkthroughable<P = any>(
12-
WrappedComponent: React.ComponentType<P>
10+
WrappedComponent: React.ComponentType<P>,
1311
) {
14-
const Component: FunctionComponent<PropsWithCopilot<P>> = ({
15-
copilot,
16-
...props
17-
}) => <WrappedComponent {...(copilot as any)} {...props} />;
12+
const Component: FunctionComponent<P> = (props: P) => {
13+
const { copilot, ...rest } = props as { copilot: CopilotType } & P;
14+
return <WrappedComponent {...copilot} {...(rest as any)} />;
15+
};
1816

1917
Component.displayName = "Walkthroughable";
2018

0 commit comments

Comments
 (0)