我正在尝试在我的 react-native 应用程序中初始化 smooch.io。按照说明将其添加到我在https://github.com/smooch/react-native-smooch找到的项目后,我将其导入到我的一个文件中并尝试从 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;