React Native Redux UI Kit For Channelize.io
This is react native redux UI Kit using Channelize.io Javascript SDKs. https://docs.channelize.io/react-native-redux
- Git clone
git clone https://github.com/ChannelizeIO/Channelize-React-Native-Redux-Chat
- Install React Native CLI
npm install -g react-native-cli
- Install npm dependencies
npm install
-
For Android: (Please see all the steps in detail in React native doc) a) Install Android Studio (https://developer.android.com/studio/index.html) b) Install Android SDK c) Configure the ANDROID_HOME environment variable d) Connect Android device or Virtual device to Android Studio
-
Run the react native application by following commands:
npm run start
npm run android
npm run ios
This is the application component which combines all the components and takes Javascript SDK client object as prop and pass this object to all all children components as props.
This component is for listing of all the conversations with a better UI. Moreover when you select a conversation, you will be navigated to ConversationWindow
component.
This component is for displaying, conversation header, message listing and message input box with a better UI. The conversation window supports conversation
and userId
props.
If you pass userId
prop, the component get conversation from userId and render message list.
If you pass conversation
prop, the component will render the message list of the input conversation.
This component renders the image and background color with initials.
This is a context provider which stores the Javascript SDk client
object in provider's value
prop and pass client object to all children components.
This is a higher order function which takes component in input, merge the context data with the input component props and return the component. This function is used to access the context data in component.
To add the components, you need channelize public key and access token which can explore more here
To add the components, you need channelize public key and access token which can explore more here
import { App, ConversationList, ConversationWindow, store } from './src';
// You can use your store file also
import { Channelize } from 'channelize-chat';
import { Provider } from 'react-redux';
export default = (props) => {
var client = new Channelize.client({publicKey: PUBLIC_KEY});
return (
<Provider store={store}>
<App client={client} userId={LOGGEDIN_USER_ID} accessToken={CH_ACCESS_TOKEN}>
<ConversationList />
<ConversationWindow />
</App>
</Provider>
)
}
import { App, ConversationWindow, store } from './src';
// You can use your store file also
import { Channelize } from 'channelize-chat';
import { Provider } from 'react-redux';
export default (props) => {
var client = new Channelize.client({publicKey: PUBLIC_KEY});
return (
<Provider store={store}>
<App client={client} userId={LOGGEDIN_USER_ID} accessToken={CH_ACCESS_TOKEN}>
<ConversationWindow userId={USER_ID}/>
</App>
</Provider>
)
}
import React, { useEffect, useState } from 'react';
import { App, ConversationWindow, store } from './src';
// You can use your store file also
import { Channelize } from 'channelize-chat';
import { Provider } from 'react-redux';
export default (props) => {
const [conversation, setConversation] = useState('');
const client = new Channelize.client({publicKey: PUBLIC_KEY});
useEffect(() => {
getConversation();
}, []);
const getConversation = async () => {
const res = await client.connect(USER_ID, ACCESS_TOKEN);
const conversation = await client.Conversation.getConversation(CONVERSATION_ID)
setConversation(conversation);
};
if (!conversation) {
return null;
}
return (
<Provider store={store}>
<App client={client} userId={LOGGEDIN_USER_ID} accessToken={CH_ACCESS_TOKEN}>
<ConversationWindow conversation={conversation}/>
</App>
</Provider>
)
}
Please follow the below steps to add UI kit into your existing app:
- Git clone the UI kit repository in a folder of your project's root directory.
- If you are already using Redux, then import all reducers from UI kit to your application's root reducer file.
- If you are not using Redux, then import
store
from UI kit in your application and passstore
inRedux Provider
before usingApp
component of UI Kit as you can see in the above examples. - See UI kit's package.json file and add the missing packages in your project's package.json file.
- Start using UI kit's components in your application component as you can see in the above examples.