electrode-react-ssr-caching icon indicating copy to clipboard operation
electrode-react-ssr-caching copied to clipboard

Propsless components not caching

Open maxpain opened this issue 9 years ago • 3 comments

If component has no props, it will not be cached.

const canCache = (opts = cacheComponents[name]) && opts.enable && !(transaction._cached ||
    _.isEmpty(saveProps) || typeof saveProps.children === "object");

Maybe remove _.isEmpty(saveProps) check?

maxpain avatar Dec 14 '16 05:12 maxpain

Seeing this as well. Stupid simple components without props are prime candidates for caching imo.

sveisvei avatar Dec 19 '16 10:12 sveisvei

When saveProps.children is null, typeof saveProps.children will return "object“

niklaus0823 avatar Dec 22 '16 07:12 niklaus0823

@niklaus0823 so is this a bug or the intended behaviour? should https://github.com/electrode-io/electrode-react-ssr-caching/blob/master/lib/ssr-caching.js#L242 be something like the below instead?

 _.isEmpty(saveProps) || (saveProps.children && typeof saveProps.children === "object"));

Can one of the core maintainers chip in on this to see if I should open PR?

anescobar1991 avatar Jun 29 '17 19:06 anescobar1991