_reactNativeSmooch2.default.show is not a function

267 Views Asked by At

I am trying to initialize smooch.io in my react-native app. After following the instructions to add it to my project found at https://github.com/smooch/react-native-smooch I am importing it in one of my files and trying to show it from ComponentDidMount(). The show method doesn't appear to be working. Any ideas on what I'm doing wrong?

import React from "react";

import Smooch from "react-native-smooch";

import {
  Body,
  Container,
  Content,
  Drawer,
  Header,
  Left,
  Right,
  Title,
} from "native-base";
import { connect } from "react-redux";
import { compose, lifecycle, toClass, withHandlers } from "recompose";

import { ClosetList } from "my-client-common/interactive";
import { Button } from "my-client-common/toolbox";

import { Things } from "my-client-common/api";

import Sidebar from "../Sidebar/";

const withThingData = lifecycle({
  componentDidMount() {
    const { getThings } = this.props;

    Smooch.show();

    getThings();
  },
});

const mapStateToProps = state => ({
  things: state.things,
});

const Closet = withThingData(
  ({ navigation, drawerRef, closeDrawer, openDrawer, things }) => (
    <Drawer
      ref={drawerRef}
      content={<Sidebar navigation={navigation} />}
      onClose={() => closeDrawer()}
    >
      <Container>
        <Header>
          <Left>
            <Button flat icon="menu" action={() => openDrawer()} />
          </Left>
          <Body>
            <Title>Closet</Title>
          </Body>
          <Right />
        </Header>
        <Content padder>
          <ClosetList data={things} />
        </Content>
      </Container>
    </Drawer>
  )
);

const ConnectedCloset = connect(mapStateToProps, dispatch => ({
  getThings: () => {
    dispatch(Things.thingsFetch());
  },
}))(Closet);

const ClosetScreenWithDrawer = compose(
  toClass,
  withHandlers(() => {
    let drawer = null;

    return {
      drawerRef: () => ref => {
        drawer = ref;
      },
      closeDrawer: () => () => {
        /* eslint-disable no-underscore-dangle */
        if (drawer) {
          drawer._root.close();
        }
        /* eslint-enable no-underscore-dangle */
      },
      openDrawer: () => () => {
        /* eslint-disable no-underscore-dangle */
        if (drawer) {
          drawer._root.open();
        }
        /* eslint-enable no-underscore-dangle */
      },
    };
  })
);

const FinalClosetScreen = ClosetScreenWithDrawer(ConnectedCloset);

FinalClosetScreen.navigationOptions = {
  header: null,
};

export default FinalClosetScreen;

0

There are 0 best solutions below