Skip to content

Commit 40f8bc4

Browse files
authored
Merge pull request #163 from Detaysoft/refs-broken-problems
messageList and messageBox converted to function component
2 parents 2adfb6e + d91acee commit 40f8bc4

File tree

28 files changed

+2943
-2815
lines changed

28 files changed

+2943
-2815
lines changed

CHANGELOG.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<details open>
2+
<summary>11.0.0 Updates</summary>
3+
<br>
4+
5+
This update target to fix component ref broken problems
6+
7+
Fixed issues:
8+
9+
- https://github.com/Detaysoft/react-chat-elements/issues/158
10+
- https://github.com/Detaysoft/react-chat-elements/issues/157
11+
- https://github.com/Detaysoft/react-chat-elements/issues/142
12+
13+
1. All react-chat-elements components turneded to function component for "ref" property problems.
14+
15+
2. In the [Input](https://github.com/Detaysoft/react-chat-elements#input-component) component `referance={...}` instead of use `ref={...}`
16+
17+
3. **10.16.2** and before vesion usage
18+
19+
**Before usage**: this.refs.input.clear();
20+
21+
After **11.0.0** version usage is:
22+
23+
```js
24+
import { Input } from 'react-chat-elements'
25+
26+
<Input
27+
ref='input'
28+
placeholder="Type here..."
29+
multiline={true}
30+
.
31+
.
32+
.
33+
/>
34+
```
35+
36+
New usage in **class component**: clearRef();
37+
38+
```js
39+
40+
import { Input } from 'react-chat-elements'
41+
let clearRef = () => {};
42+
this.inputReferance = React.createRef();
43+
44+
<Input
45+
referance={this.inputReferance}
46+
clear={(clear) => clearRef = clear}
47+
placeholder="Type here..."
48+
multiline={true}
49+
.
50+
.
51+
.
52+
/>
53+
54+
```
55+
56+
New usage in **function component**: clearRef();
57+
58+
```js
59+
60+
import { Input } from 'react-chat-elements'
61+
let clearRef = () => {};
62+
const inputReferance = React.useRef();
63+
64+
<Input
65+
referance={inputReferance}
66+
clear={(clear) => clearRef = clear}
67+
placeholder="Type here..."
68+
multiline={true}
69+
.
70+
.
71+
.
72+
/>
73+
74+
```
75+
76+
4. In the [MessageList](https://github.com/Detaysoft/react-chat-elements#messagelist-component) component usage `referance={...}` instead of use `ref={...}`
77+
78+
**Class Component:**
79+
80+
```js
81+
import { MessageList } from 'react-chat-elements'
82+
this.messageList = React.createRef();
83+
84+
<MessageList
85+
referance={this.messageList}
86+
className='message-list'
87+
lockable={true}
88+
toBottomHeight={'100%'}
89+
dataSource={[
90+
{
91+
position: 'right',
92+
type: 'text',
93+
text: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit',
94+
date: new Date(),
95+
},
96+
.
97+
.
98+
.
99+
]} />
100+
```
101+
102+
**Function Component:**
103+
104+
```js
105+
import { MessageList } from 'react-chat-elements'
106+
const messageListReferance = React.useRef();
107+
108+
<MessageList
109+
referance={messageListReferance}
110+
className='message-list'
111+
lockable={true}
112+
toBottomHeight={'100%'}
113+
dataSource={[
114+
{
115+
position: 'right',
116+
type: 'text',
117+
text: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit',
118+
date: new Date(),
119+
},
120+
.
121+
.
122+
.
123+
]} />
124+
```
125+
126+
</details>

README.md

Lines changed: 359 additions & 362 deletions
Large diffs are not rendered by default.

example/App.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,13 @@ button {
5050
height: 50px;
5151
background: red;
5252
}
53+
54+
.on-drag-mlist {
55+
width: 100%;
56+
height: 100%;
57+
background-color: #e2f3f5;
58+
display: flex;
59+
justify-content: center;
60+
align-items: center;
61+
z-index: 999;
62+
}

0 commit comments

Comments
 (0)