NickyMeuleman / nicky-blog

https://nickymeuleman.netlify.app/
14 stars 6 forks source link

ERROR #95313 when building #170

Closed NickyMeuleman closed 1 year ago

NickyMeuleman commented 2 years ago

WebpackError: TypeError: Cannot read properties of undefined (reading 'includes')

const Div = ({ className, children, ...rest }) => {
> 6 |   if (className.includes(`math-display`)) {
    |                 ^
  7 |     return <MathBlock math={children} {...rest} />;
  8 |   }
  9 |   return (

This happens because there is no className before remark-math adds it to a block. This causes includes to be called on undefined.

Hint: optional chaining to not call includes if there is no className yet.