But if at every update (every keystroke of the user), the algorithm needs to go through millions of lines of text to determine which ones to show, it is going to be slow, even if eventually only e.g. 50 lines are shown.
For a game, there's some sophisticated math involved. But for a text editor? You only need to perform basic arithmetic on the scroll position and window height to index in to a vector of lines.
In React, you could render exactly 50 <Line> components and choose which 50 by exactly the same means vim chooses which 50 ncurses lines to show.