Closed quolpr closed 2 years ago
Like, the server component uses SQL query:
https://github.com/reactjs/server-components-demo/blob/main/src/NoteList.server.js#L20
And I don't see any subscription to the result of the query(so the server or client will not get known that the new rows appear in DB), and that's why I am curious, what is the logic of how React decides to refetch server component.
Also, the question is not about the topic, but I am curious - will React have a mechanism to push(for example via WebSockets) server-rendered components to the client?
The search field updates a piece of context:
Our root client shell component reads a (cacheable) server response according to that piece of context:
So when you change the field, effectively you tell React to refetch the server tree. Similar to navigating to another page.
So there are no subscriptions involved, it's more like refreshing the page. (But because it's built with React, the page doesn't "reset" during a refresh.)
Hope that helps.
First of all, thank you for a great example 🙂️. And thank you for keeping in touch with what React dev team is working on. That's a great thing!
For example, when I create a new note with the title
test
and I already have search input withtest
, how react decide that the search result should be rerendered on the server? This thing is not clear to me 🤔️