Closed MartinXPN closed 1 year ago
Hi! Have you checked the changelog before upgrading?
Particularly this: https://github.com/remarkjs/react-markdown/blob/main/changelog.md#remove-extra-props-passed-to-certain-components
Thanks a lot for the prompt reply @Murderlon ! So, is there a way to distinguish between inline vs block code components in the new version? I'm not sure how to properly migrate the code by reading the changelog to be honest.
Does this mean that we don't need to check for the inline
property at all and it's handled differently?
This is some pseudo-code I typed without testing but probably something like this. I think you can also use pre: () => {}
in components
for code block components.
import {visit} from 'unist-util-visit'
function rehypeInlineCodeProperty() {
/**
* @param {import('hast').Root} tree
* @returns {undefined}
*/
return function (tree) {
visit(tree, 'code', function (node, index, parent) {
if (parent && parent.tagName === 'pre') {
node.properties.inline = false;
} else {
node.properties.inline = true;
}
})
}
}
Hi! Thanks for reaching out! Because we treat issues as our backlog, we close issues that are questions since they don’t represent a task to be completed.
See our support docs for how and where to ask questions.
Thanks, — bb
And how do we get code language like using class-name
in v8?
That didn’t change.
It does not work at all, className is undefined
Nope.
Can you read the support guide on how to ask questions: you need to provide information.
In v8, I was able to get the language of above code using className
prop. However, in this release, there's no className or props passed to pre
at all.
I removed the custom renderer of pre
and DevTools shows this:
Nevermind, the actual props were passed to inner code element.
Take a look at this example. You probably want to use code
not pre
for this: https://github.com/remarkjs/react-markdown#use-custom-components-syntax-highlight
Thanks.
Initial checklist
Affected packages and versions
"react-markdown": "^9.0.0",
Link to runnable example
No response
Steps to reproduce
I have the following component that used to work fine:
Now, I get the following errors:
I'm using node@18.17.0 with next@13.5.4
Expected behavior
It used to work fine using the previous version
Actual behavior
The code does not compile
Runtime
Other (please specify in steps to reproduce)
Package manager
yarn 2
OS
Linux, macOS
Build and bundle tools
Next.js