mohebifar / react-native-copilot

Step-by-step walkthrough tooltip for your react native app
MIT License
2.22k stars 406 forks source link

Tutorial does not show, this.props.start is undefined. #97

Open hoanghcmus opened 5 years ago

hoanghcmus commented 5 years ago

Current Behavior Tutorial does not show when involve this.props.start()

Input Code

import React, { Component } from 'react';

...
...

import {Spinner, Label, View, StyleProvider, Container, List, ListItem, Left, Thumbnail, Right, Header, Content, Form, Footer, FooterTab, Button, Icon, Badge, Card, CardItem, Text, Body } from 'native-base';

...
...

// TODO: IMport Copilot module
import { copilot, walkthroughable, CopilotStep } from '@okgrow/react-native-copilot';

// TODO: Declare walkthrouh element
const CopilotText = walkthroughable(Text);

class Annoucement extends Component {
  static navigationOptions = {
    title: 'Annoucement',
    drawerIcon: (
      <Icon type='Ionicons' name='md-home' style={globalStyles.sideMenuIcon}/>
    )
  }

  constructor(props) {
    super(props);
    this.state = { 
      ...
      ...
    };
  }

....
....

handleStartButtonPress() {
  console.log(`hcmus 2: Props: ${JSON.stringify(this.props.start)}`);  // TODO: Alway undefined
}

componentDidMount() {
  console.log(`hcmus 1: Props: ${JSON.stringify(this.props.start)}`); // TODO: Alway undefined
  this.props.copilotEvents.on('stepChange', this.handleStepChange);

  // TODO: Start tutorial --> NO thing happen. Even if invole props.start fron a button's click even, still not show tutorial, nothing happen
  this.props.start();
}

handleStepChange = (step) => {
  console.log(`hcmus 3: Current step is: ${step.name}`);
}

render() {
    return (

      <StyleProvider style={getTheme(platform)}>
      <Root>
      {/* <CopilotStep text="This is a hello world example!" order={1} name="hello">
          <CopilotText onPress={() => this.handleStartButtonPress()}>Hello world!</CopilotText>
        </CopilotStep> */}
      <Container>
      <CustomHeader title='Dashboard'/>

      // TODO: Here is place define step
      <CopilotStep text="This is a hello_222 world example!" order={2} name="hello_222">
          <CopilotText onPress={() => this.handleStartButtonPress()}>Hello world 2222!</CopilotText>
      </CopilotStep>

     ...
     ... 

      </Container>
      {this.state.loading &&
        <View style={globalStyles.loading}>
          <Spinner color='white' />
        </View>
      }
      </Root>
      </StyleProvider>
    );
  }
}

// TODO: export copilot
export default copilot({
  animated: true, // Can be true or false
  overlay: 'svg', // Can be either view or svg
})(Annoucement);

Expected behavior/code The tutorial should be shown when invoking the this.props.start()

Environment

Possible Solution It could be related to react-navigation, I think, but not sure,

Additional context/Screenshots screenshot_1545207647

export-mike commented 5 years ago

I'm using plain old react-native init and copilot is not showing for me. I'm also using react-navigation.

DimiTech commented 5 years ago

As I see @hoanghcmus is using native-base UI framework.. this might be the problem ?

DimiTech commented 5 years ago

@hoanghcmus Try wrapping a react-native View component and with walkthroughable and then use that walkthroughable View to wrap your desired elements.

Arya-Aghaei commented 5 years ago

@DusanDimitric I am also using native-base and I tried your suggestion, and there was not any progress, It works in my main screen, but it does not work in others :|

rgordon95 commented 5 years ago

Instead of const CopilotText = walkthroughable(Text); do const CopilotText = walkthroughable(View);