webpack-ant-icon-loader icon indicating copy to clipboard operation
webpack-ant-icon-loader copied to clipboard

SSR mismatch warning

Open revskill10 opened this issue 6 years ago • 3 comments

I faced one problem with SSR: there's a mismatch which says server code doesn't contain path inside svg element.

revskill10 avatar Mar 16 '19 18:03 revskill10

Hi, can you provide more detailed inforomation ?

Beven91 avatar Mar 18 '19 05:03 Beven91

Some react developers use Ant Design Component in a Server Side Render project such as react-dom/server or next.js. The server rendering required the react component tree is the same between Server Side Rendering/Client Side Hydration. If not, the browser console will emit a warning like this:

Warning: Did not expect server HTML to contain a `<Child>` in `<Parent>`

in which Child and Parent denotes to the CSR components that are rendered differently in SSR.

So I am considering it is the problem that the webpack loader makes the @ant-design/icons different between server and browser compilation.

You can reproduce the issue when using next.js.

I suggest that making an alias resolver in webpack config for @ant-design/icons temporarily that only exports the icons used in your project, if you want tree shaking feature for ant icons. Or otherwise ignore that warnings.

tangye1234 avatar Apr 28 '19 07:04 tangye1234

Yes, you are right, i will add feature to resovle it.

Beven91 avatar Apr 28 '19 12:04 Beven91