Code Monkey home page Code Monkey logo

Comments (14)

bmathews avatar bmathews commented on May 18, 2024 1

I believe the template is supposed to be:
${() => componentRenderer.checksum()}

instead of:
${componentRenderer.checksum()}

from rapscallion.

divmain avatar divmain commented on May 18, 2024

I believe this was a regression. I'll have a fix (and regression test) out for this tomorrow @marcohamersma. Thanks for the report!

from rapscallion.

tom2strobl avatar tom2strobl commented on May 18, 2024

Hi there, are there any updates? I'm also down for an ugly hack in the meantime – can't get the checksum running in any way somehow.

from rapscallion.

tom2strobl avatar tom2strobl commented on May 18, 2024

@divmain I tried to get the .checksum() from the responseRenderer, but that obviously doesn't work. Then I tried to call componentRenderer.toStream() manually, but that's not getting anywhere either. The componentRenderer lacks this._stream, but I have no idea how it should get one if I can't call toStream().
Does it mean currently you can't get the checksum feature if you use the responseRenderer?

from rapscallion.

divmain avatar divmain commented on May 18, 2024

@tom2strobl @marcohamersma Sorry for the delay on this. Real life interrupted :). Fix is in branch fix-stream-checksums and published to rapscallion@next. Would one of you be willing to install and check that this is resolved for you?

from rapscallion.

tom2strobl avatar tom2strobl commented on May 18, 2024

No worries, this is Open Source and you're doing it for free so there can't be a delay :-)
I tried npm i -S rapscallion@next which installed 2.1.2, unfortunately it seems to still persist, here's my (shortened) use case:

const componentRenderer = render(<Component {...data} />);
const responseRenderer = template`
  // [...]
  <div id="app-mount">${componentRenderer}</div>
  // [...]
  <script id="app-state">
    window.state = ${() => JSON.stringify(data)}
    document.querySelector("#app-mount").setAttribute("data-react-checksum", "${componentRenderer.checksum()}")
  </script>
`;
const stream = responseRenderer.toStream();
// "this" is in that case a hapi reply interface, so don't worry about it – that part works
this(stream);

It throws:

2017-03-15/10:27:03:041, [error] message: Renderer#checksum can only be invoked for a renderer converted to node stream. stack: Error: Renderer#checksum can only be invoked for a renderer converted to node stream.
    at Renderer.checksum (/.../node_modules/rapscallion/lib/renderer.js:56:15)

Am I using it wrong?

from rapscallion.

divmain avatar divmain commented on May 18, 2024

So... I may have forgotten to npm run build before publishing 🔨 Try it now, you should see v2.1.3 available under the next tag.

from rapscallion.

tom2strobl avatar tom2strobl commented on May 18, 2024

Interesting, it now throws

    TypeError: Cannot read property 'toString' of undefined
    at Renderer.checksum (/.../node_modules/rapscallion/lib/renderer.js:82:28)

from rapscallion.

KittyGiraudel avatar KittyGiraudel commented on May 18, 2024

Seconded. 2.1.1 throws Renderer#checksum can only be invoked for a renderer converted to node stream., 2.1.3 throws Cannot read property 'toString' of undefined.

from rapscallion.

divmain avatar divmain commented on May 18, 2024

Can one of you throw up a gist that reproduces? I need something to work against.

from rapscallion.

divmain avatar divmain commented on May 18, 2024

Shoot, the docs are wrong. Thank you for pointing that out @bmathews. I'll fix that in my branch.

from rapscallion.

mtsewrs avatar mtsewrs commented on May 18, 2024

@bmathews this and v2.1.3 solved the problem for me

from rapscallion.

divmain avatar divmain commented on May 18, 2024

Thanks everybody. I move these changes into master and publish to latest.

from rapscallion.

divmain avatar divmain commented on May 18, 2024

Published as v2.1.4.

from rapscallion.

Related Issues (20)

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.