Skip to content

Commit 32f0a34

Browse files
authored
Merge pull request #2402 from FaridSafi/functional-example
refactor(example): change to functional component
2 parents cb997c1 + 8c095b7 commit 32f0a34

4 files changed

Lines changed: 265 additions & 246 deletions

File tree

README.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,14 @@
6767
</p>
6868
</p>
6969

70-
## The future of GiftedChat 🎉
70+
## The future of GiftedChat 🎉
71+
7172
Please give us your advice: [Related PR](https://github.com/FaridSafi/react-native-gifted-chat/pull/1775)
7273

7374
## Please vote
7475

7576
**GiftedChat** depends on other packages and some needs a boost, please vote for PRs will improve it, thanks:
77+
7678
- https://github.com/watadarkstar/react-native-typing-animation/issues/18
7779

7880
## Features
@@ -100,23 +102,24 @@ Please give us your advice: [Related PR](https://github.com/FaridSafi/react-nati
100102
- Use version `0.0.10` for RN `< 0.40.0`
101103

102104
## Testing
105+
103106
`Test_ID` is exported as constants that can be used in your testing library of choice
104107

105-
Gifted Chat uses `onLayout` to determine the height of the chat container. To trigger `onLayout` during your tests, you can run the following bits of code.
108+
Gifted Chat uses `onLayout` to determine the height of the chat container. To trigger `onLayout` during your tests, you can run the following bits of code.
106109

107110
```typescript
108111
const WIDTH = 200 // or any number
109112
const HEIGHT = 2000 // or any number
110113

111-
const loadingWrapper = getByTestId(Test_ID.LOADING.WRAPPER)
112-
fireEvent(loadingWrapper, "layout", {
114+
const loadingWrapper = getByTestId(TEST_ID.LOADING_WRAPPER)
115+
fireEvent(loadingWrapper, 'layout', {
113116
nativeEvent: {
114117
layout: {
115118
width: WIDTH,
116119
height: HEIGHT,
117120
},
118121
},
119-
});
122+
})
120123
```
121124

122125
## Installation
@@ -143,7 +146,7 @@ import React, { useState, useCallback, useEffect } from 'react'
143146
import { GiftedChat } from 'react-native-gifted-chat'
144147

145148
export function Example() {
146-
const [messages, setMessages] = useState([]);
149+
const [messages, setMessages] = useState([])
147150

148151
useEffect(() => {
149152
setMessages([
@@ -161,7 +164,9 @@ export function Example() {
161164
}, [])
162165

163166
const onSend = useCallback((messages = []) => {
164-
setMessages(previousMessages => GiftedChat.append(previousMessages, messages))
167+
setMessages(previousMessages =>
168+
GiftedChat.append(previousMessages, messages),
169+
)
165170
}, [])
166171

167172
return (

0 commit comments

Comments
 (0)