import {compose} from "recompose";
import TopicsSingleScreenEnh from "../TopicsSingleScreen";
import withActiveCallBacks from "../../navigators/react-navigation-addons/withActiveCallBacks";
import {withNavigation} from "../../components/hocs/withNavigation";
import PropTypes from "prop-types";
import withLoadTopic from "../../components/hocs/withLoadTopic";
/**
* You can use this component to display your Discussion/Topic single screen in your custom screen.
* @component
* @example <caption> Use TopicSingleScreen in custom navigation route "book" </caption>
* //In custom_code/components/MyCustomScreen.js
*
* import React from 'react';
* import TopicSingleScreen from '@src/containers/Custom/TopicSingleScreen';
*
* const MyCustomScreen = (props) => {
*
* const topicId = 149; //Pass id of topic to load
* const searchTerm = "Performance" //Pass search term to get a direct result
*
* if (! props.isFocused)
* return null;
*
* return <TopicSingleScreen topicId={topicId} searchTerm={searchTerm}/>
*
* }
*
*
* export default MyCustomScreen;
*
* //In custom_code/index.js...
*
* ...
*
* import MyCustomScreen from "./components/MyCustomScreen";
*
* export const applyCustomCode = externalCodeSetup => {
*
* externalCodeSetup.navigationApi.addNavigationRoute(
* "book",
* "BookScreen",
* MyCustomScreen,
* "All"
* );
* externalCodeSetup.navigationApi.addNavigationRoute(
* "book",
* "BookScreen",
* MyCustomScreen,
* "Main"
* );
* }
*
*/
const TopicSingleScreen = compose(
withNavigation,
withActiveCallBacks
)(TopicsSingleScreenEnh);
export default withLoadTopic(TopicSingleScreen);
TopicSingleScreen.propTypes = {
/**
* The id of the topic to display
* {Number}
*/
topicId: PropTypes.number.isRequired,
/**
* If the topic is not yet available in the app state, the component will attempt to a list of topics.
* You can use this field to search for the specific topic you want to load instead of loading a list of topics.
* {String}
*/
searchTerm: PropTypes.string,
/**
* Use this to display your own loading component while the screen is loading
* {ReactComponent}
*/
LoadingComponent: PropTypes.elementType
};
Source