import React from 'react'; import PropTypes from 'prop-types'; import { FlatList, Text, View } from 'react-native'; import { connect } from 'react-redux'; import LoggedView from '../View'; import { openSnippetedMessages, closeSnippetedMessages } from '../../actions/snippetedMessages'; import styles from './styles'; import Message from '../../containers/message'; const renderItem = ({ item }) => ( {}} /> ); @connect( state => ({ messages: state.snippetedMessages.messages, user: state.login.user, baseUrl: state.settings.Site_Url || state.server ? state.server.server : '' }), dispatch => ({ openSnippetedMessages: rid => dispatch(openSnippetedMessages(rid)), closeSnippetedMessages: () => dispatch(closeSnippetedMessages()) }) ) export default class SnippetedMessagesView extends LoggedView { static propTypes = { navigation: PropTypes.object, messages: PropTypes.array, user: PropTypes.object, baseUrl: PropTypes.string, openSnippetedMessages: PropTypes.func, closeSnippetedMessages: PropTypes.func } constructor(props) { super('SnippetedMessagesView', props); } componentDidMount() { this.props.openSnippetedMessages(this.props.navigation.state.params.rid); } componentWillUnmount() { this.props.closeSnippetedMessages(); } renderEmpty = () => ( No snippet messages ) render() { if (this.props.messages.length === 0) { return this.renderEmpty(); } return ( item._id} /> ); } }