@@ -156,10 +156,10 @@ const MesssageView = observer((props) => {
156156
157157``` tsx
158158import { types } from ' mobx-state-tree' ;
159- import { createQuery , RequestModel } from ' mst-query' ;
159+ import { createInfiniteQuery , RequestModel } from ' mst-query' ;
160160import { MessageModel } from ' ./models' ;
161161
162- const MessagesQuery = createQuery (' MessagesQuery' , {
162+ const MessagesQuery = createInfiniteQuery (' MessagesQuery' , {
163163 data: types .model ({ items: types .array (types .reference (MessageModel )) }),
164164 pagination: types .model ({ offset: types .number , limit: types .number }),
165165 endpoint({ request }) {
@@ -175,13 +175,13 @@ const MessageStore = createModelStore('MessageStore', MessageModel).props({
175175```
176176
177177``` tsx
178- import { useQuery } from ' mst-query' ;
178+ import { useInfiniteQuery } from ' mst-query' ;
179179import { observer } from ' mobx-react' ;
180180import { MessageListQuery } from ' ./MessageListQuery' ;
181181
182182const MesssageListView = observer ((props ) => {
183183 const [offset, setOffset] = useState (0 );
184- const { data, isFetchingMore, query } = useQuery (messageStore .messagesQuery , {
184+ const { data, isFetchingMore, query } = useInfiniteQuery (messageStore .messagesQuery , {
185185 request: { filter: ' ' },
186186 pagination: { offset , limit: 20 },
187187 });
@@ -246,9 +246,11 @@ const AddMessage = observer((props) => {
246246 onClick = { () => {
247247 addMessage ({
248248 request: { message },
249- optimisticResponse: {
250- id: ' temp' + Math .random (),
251- message ,
249+ optimisticUpdate() {
250+ return {
251+ id: ' temp' + Math .random (),
252+ message ,
253+ };
252254 },
253255 });
254256 setMessage (' ' );
0 commit comments