SSRvsCSR
The most difficult challenge with server side rendering when building a react, react-router, redux app is.
We need some way to detect when all initial data load action creators are completed on the server. On the server, when we try to fetch some data with an action creator, we need to know the exact instance the request is finished, so we can attempt to render the app as a string and send it back down to the browser.
How is this accomplished you might ask? It just so happens I have a solution to the most difficult problem.
1. Figure out what components should have rendered when a user navigates to a certain url.
2. Call the functions that are attached the components that handle loading data and then wait for a response.
3. Detect when those those promises are finished
4. Render app with all the data loaded into each component
5. Send result down to the browser to the use can see the results
What do you know. I actually have an example presentation showcasing this EXACT situation.
On the right is an instance of the app the fetches the list of users from the api and renders on the information on the client.
On the left is an instance of the app that fetches the list of users from the api and renders the information on the server, then sends it down to the client. Look closely at the network tab. Notice a difference?
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «SSRvsCSR», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.