Step-by-step walkthrough for your react native app
npm install --save @okgrow/react-native-copilot
Use the copilot()
higher order component for the screen component that you want to use copilot with:
import { copilot } from '@okgrow/react-native-copilot';
class HomeScreen extends Component { /* ... */ }
export default copilot()(HomeScreen);
Before defining walkthrough steps for your react elements, you must make them walkthroughable
. The easiest way to do that for built-in react native components, is using the walkthroughable
HOC. Then you must wrap the element with CopilotStep
.
import { copilot, walkthroughable, CopilotStep } from '@okgrow/react-native-copilot';
const CopilotText = walkthroughable(Text);
class HomeScreen {
render() {
return (
<View>
<CopilotStep text="This is a hello world example!" order={1} name="hello">
<CopilotText>Hello world!</CopilotText>
</CopilotStep>
</View>
);
}
}
Every CopilotStep
must have these props:
- name: A unique name for the walkthrough step.
- order: A positive number indicating the order of the step in the entire walkthrough.
- text: The text shown as the description for the step.
The components wrapped inside CopilotStep
, will receive a copilot
prop of type Object
which the outermost rendered element of the component or the element that you want the tooltip be shown around, must extend.
import { copilot, CopilotStep } from '@okgrow/react-native-copilot';
const CustomComponent = ({ copilot }) => <View {...copilot}><Text>Hello world!</Text></View>;
class HomeScreen {
render() {
return (
<View>
<CopilotStep text="This is a hello world example!" order={1} name="hello">
<CustomComponent />
</CopilotStep>
</View>
);
}
}
Use this.props.start()
in the root component in order to trigger the tutorial. You can either invoke it with a touch event or in componentDidMount
. Note that the component and all its descendants must be mounted before starting the tutorial since the CopilotStep
s need to be registered first.
Issues and Pull Requests are always welcome.
Please read OK GROW!'s global contribution guidelines.
If you are interested in becoming a maintainer, get in touch with us by sending an email or opening an issue. You should already have code merged into the project. Active contributors are encouraged to get in touch.
Please note that all interactions in @okgrow's repos should follow our Code of Conduct.
MIT © 2017 OK GROW!, https://www.okgrow.com.