mohebifar / mohebifar/react-native-copilot

How do I pass a custom prop into my custom tooltip component?

Open
#118 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.4k
Forks
428
PR merge metrics
No merged PRs in 30d

Description

Given this working code, with a component like this:

interface CopilotTooltipProps {
  screen: string;
  isFirstStep: boolean;
  isLastStep: boolean;
  currentStep: any;
  handleNext(): void;
  handlePrev(): void;
  handleStop(): void;
}

const CopilotTooltip: React.SFC<CopilotTooltipProps> = (props) => {
  const { screen, isFirstStep, isLastStep, currentStep, handleNext, handlePrev, handleStop } = props;
  console.log('screen is', screen);
  return <View>
  <View style={styles.tooltipContainer}>
    <Text testID="stepDescription" style={styles.tooltipText}>{currentStep.text}</Text>
  </View>
  <View style={[styles.bottomBar]}>
    {
      !isLastStep ?
        <TouchableOpacity onPress={handleStop}>
          <View style={[styles.button]}>
            <Text style={[styles.buttonText]}>Skip</Text>
          </View>
        </TouchableOpacity>
        : null
    }
    {
      !isFirstStep ?
        <TouchableOpacity onPress={handlePrev}>
          <View style={[styles.button]}>
            <Text style={[styles.buttonText]}>Previous</Text>
          </View>
        </TouchableOpacity>
        : null
    }
    {
      !isLastStep ?
        <TouchableOpacity onPress={handleNext}>
          <View style={[styles.button]}>
            <Text style={[styles.buttonText]}>Next</Text>
          </View>
        </TouchableOpacity> :
        <TouchableOpacity onPress={handleStop}>
          <View style={[styles.button]}>
            <Text style={[styles.buttonText]}>Finish</Text>
          </View>
        </TouchableOpacity>
    }
  </View>
</View>;
};

used in a screen like so:

export default copilot({
  tooltipComponent: CopilotTooltip
})(Home);

how do I pass in the variable screen, while making sure all the other props have the same behaviour as when it's defined as above in my Home screen?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the CopilotTooltipProps interface and the copilot({ tooltipComponent: CopilotTooltip })(Home) entry point shown in the issue. Trace how tooltipComponent receives its props and determine how a screen value could be documented alongside the existing injected props. Done means the supported usage and prop behavior are clearly explained.

Written by the indexing model from the issue text.

Assessment

Tech stack
react-native, typescript
Domain
documentation, mobile
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.