Closed JakeH987 closed 3 years ago
`import React, { Component } from 'react' import { connect } from 'react-redux' import { bindActionCreators } from 'redux' import LoginPage from './LoginPage' import { logout } from '../Actions/Accounts' import { ChatEngine, MessageForm } from 'react-chat-engine'
class ChatsPage extends Component { adminChat = (9081 || 22498)
render() { if (!localStorage.getItem('username')) return <LoginPage /> return ( <div style={{ position: 'absolute', top: '0px', width: '100%' }}> <ChatEngine height='100vh' userName={this.props.accounts.userName} userSecret={this.props.accounts.userSecret} projectID={this.props.accounts.projectID} //onGetChats={(chats) => console.log(chats)} renderNewChatForm={(creds) => <div />} renderNewMessageForm={(props, chatId) => chatId !== this.adminChat && <MessageForm {...props} chatId={chatId} />} /> this.addNewPerson() <button className="logoutButton" onClick={() => this.props.logout()} style={{ position: 'absolute', bottom: '12px', right: '12px', backgroundColor: '#92a1ef' }} > Logout </button> </div> ) }
}
function mapStateToProps(state){ return { accounts: state.accounts } }
function mapDispatchToProps(dispatch){ return bindActionCreators({ logout }, dispatch) }
export default connect(mapStateToProps, mapDispatchToProps)(ChatsPage)`
At the moment, it's called NewMessageForm not MessageForm
See more here: https://github.com/alamorre/react-chat-engine/blob/9368257eaa7803e5157aa8797084699e8e19fb5a/src/index.js#L26
`import React, { Component } from 'react' import { connect } from 'react-redux' import { bindActionCreators } from 'redux' import LoginPage from './LoginPage' import { logout } from '../Actions/Accounts' import { ChatEngine, MessageForm } from 'react-chat-engine'
class ChatsPage extends Component { adminChat = (9081 || 22498)
}
function mapStateToProps(state){ return { accounts: state.accounts } }
function mapDispatchToProps(dispatch){ return bindActionCreators({ logout }, dispatch) }
export default connect(mapStateToProps, mapDispatchToProps)(ChatsPage)`