-
Notifications
You must be signed in to change notification settings - Fork 278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[sitecore-jss-react] Remove use of reactDom/server
from React Image
#1544
Conversation
reactDom/server
from client bundle
reactDom/server
from client bundlereactDom/server
from react Image
reactDom/server
from react ImagereactDom/server
from React Image
@sc-addypathania Great finding! |
@sc-addypathania Don't forget to close related issue #1280 and leave the comment there |
if (!imgAttrs) { | ||
return getEditableWrapper(imageField.editable); | ||
} | ||
|
||
const imgHtml = ReactDOMServer.renderToStaticMarkup(<img {...imgAttrs} />); | ||
const imgHtml = `<img ${getAttributesString( | ||
imgAttrs as { [key: string]: string | number | boolean | Record<string, unknown> } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To simplify this cast action, the getAttributesString can accept { [key: string]: unknown }. In this case, you don't need to cast the type, and I'm not sure that it will make getAttributesString more complex, it also can accept the same type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm yes you're right. This simplified it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 👍
Replaced
reactDom/server
'srenderStaticMarkup
function with a custom template literals forimgHtml
asreactDom/server
bloated the client bundle size of the app.Description / Motivation
Testing Details
Types of changes