Skip to content

Commit 5642d15

Browse files
authored
Merge pull request #292 from GetStream/suggestions-docs-tweaks
suggestions docs update
2 parents 4f65a29 + 3e16861 commit 5642d15

File tree

3 files changed

+26
-25
lines changed

3 files changed

+26
-25
lines changed

src/components/SuggestionsProvider/SuggestionsProvider.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import { findNodeHandle, View } from 'react-native';
44
import { SuggestionsContext } from '../../context';
55
import SuggestionsList from './SuggestionsList';
66

7+
/**
8+
*
9+
* This provider component exposes the properties stored within the SuggestionsContext.
10+
*/
711
const SuggestionsProvider = ({ children }) => {
812
const [componentType, setComponentType] = useState('');
913
const [suggestions, setSuggestions] = useState({});
Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,28 @@
1-
Message input component supports suggestions feature. Suggestions are displayed using the popup which contains a list of suggestion items.
2-
All the functionality is abstracted out to a higher order component called [SuggestionsProvider](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/SuggestionsProvider.js). This HOC provides a context containing following functions to underlying components which consume this context:
1+
The MessageInput component supports a suggestions feature. Suggestions are displayed using a popup which contains a list of the suggestion items. All functionality is saved in the SuggestionsContext and can be accessed through the [SuggestionsProvider](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/SuggestionsProvider.js) higher order component. This HOC provides the following functions to its underlying child components:
32

4-
- **setInputBoxContainerRef** Function to set ref on input box container.
5-
- **openSuggestions** Opens the suggestions popup on input box (whose ref is set by setInputBoxContainerRef)
3+
- **closeSuggestions** {function} Closes the suggestions popup above the input box
4+
- **openSuggestions** {function} Opens the suggestions popup above the input box
65

7-
**Params**
6+
**Params:**
87

9-
- `title` {string} Title/header for suggestions suggestions popup
10-
- `component` A UI component to be used as item in suggestions list. It should be either functional component or react class component.
8+
- **title:** Title for the suggestions popup
9+
- **component:** UI component used to display each item in the suggestions list
10+
- **setInputBoxContainerRef** {function} Sets a ref on the text input box container
11+
- **updateSuggestions** {function} Updates the suggestions in the suggestions popup
1112

12-
- **closeSuggestions** Closes the suggestions popup on input box (whose ref is set by setInputBoxContainerRef)
13-
- **updateSuggestions** Updates the suggestions in suggestions popup.
13+
**Params:**
1414

15-
**Params**
15+
- **suggestions:** Array of suggestion objects
1616

17-
- `suggestions` {array} Array of suggestion objects
17+
**Example:**
1818

19-
Example of suggestion object:
20-
21-
```json
22-
{
23-
data: [
24-
'suggestion 1',
25-
'suggestion 2',
26-
'suggestion 3',
27-
...
28-
],
29-
onSelect: (suggestionItem) => { ... },
30-
}
31-
```
19+
```json
20+
{
21+
data: [
22+
'suggestion 1',
23+
'suggestion 2',
24+
'suggestion 3',
25+
],
26+
onSelect: (suggestionItem) => { ... }
27+
}
28+
```
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Any component can be made a consumer of [SuggestionsContext](#suggestionscontext) by using function `withSuggestionsContext`.
1+
Any component can be made a consumer of the [SuggestionsContext](#suggestionscontext) by using the `withSuggestionsContext` higher order component.

0 commit comments

Comments
 (0)