0

反応ネイティブ アプリで smooch.io を初期化しようとしています。https://github.com/smooch/react-native-smoochにあるプロジェクトに追加する手順に従って、ファイルの 1 つにインポートし、ComponentDidMount() から表示しようとしています。show メソッドが機能していないようです。私が間違っていることについてのアイデアはありますか?

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;

4

0 に答える 0