Coder Social home page Coder Social logo

Comments (2)

maximenajim avatar maximenajim commented on September 23, 2024

@vcarel are you able to create a unit test to reproduce this issue?

Here is a quick test I wrote...

it("should not generate wrong images URLs", () => {
    clearRequireCache();
    let renderCount = 0;
    /* eslint-disable max-params, no-console*/
    reactComponentCache({
      components: {
        "ImgComponent": {
          cacheAttrs: ["url"]
        }
      }
    });
    /* eslint-enable max-params, no-console*/
    const React = require("react");
    const ReactDomServer = require("react-dom/server");
    class ImgComponent extends React.Component {
      render() {
        renderCount++;
        return React.createElement(
            "div",
            null,
            React.createElement("img", { src: this.props.url }));
      }
    }

    // Cache Miss
    console.log("First Render:", ReactDomServer.renderToString(React.createFactory(ImgComponent)({url: "/static/media/logo.5d5d9eef.svg"})));
    expect(renderCount).to.equal(1);
    // Cache Hit
    console.log("From Cache:  ", ReactDomServer.renderToString(React.createFactory(ImgComponent)({url: "/static/media/logo.5d5d9eef.svg"})));
    expect(renderCount).to.equal(1);
  });

...but the rendered string coming from the cache looks fine:

First Render: <div data-reactid=".2das182g8ao" data-react-checksum="1530602672"><img src="/static/media/logo.5d5d9eef.svg" data-reactid=".2das182g8ao.0"/></div>
From Cache:   <div data-reactid=".2ash97u9log" data-react-checksum="2134320484"><img src="/static/media/logo.5d5d9eef.svg" data-reactid=".2ash97u9log.0"/></div>

from react-ssr-optimization.

vcarel avatar vcarel commented on September 23, 2024

Hi, actually it was a mistake from my side. My apologize :-)

from react-ssr-optimization.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.