Test your knowledege

  1. What is the difference between the render() function from react-dom and the renderToString() function from react-dom/server?
    1. The render() function is only used to sync React component content with the DOM in a browser. The renderToString() function doesn't require a DOM because it renders markup as a string.
    2. The two functions are interchangeable.
    3. The render() function is slower on the server so renderToString() is a better option.
    4. You should only use render() in the browser if you have to. The renderToString() function is preferable in most cases.
  2. Routing on the server is necessary because:
    1. Without routing on the server, there's no way to actually render components.
    2. You don't need to worry about rendering on the server since the routes will be handled in the browser.
    3. The router on the server will determine that content is rendered based on the requested URL. This content is then sent to the browser so that the user perceives a faster load time.
    4. Routing on the server should be down manually instead of using components from react-router.
  3. What function should you use when reconciling server-rendered React markup with React components in the browser?
    1. Always use render() in the browser. It knows how to make changes to existing markup that are necessary. 
    2. Always use hydrate() when the server sends rendered React components. Unlike render(), hydrate() expects rendered component markup and can handle it efficiently.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.140.186.201