Skip to content

Commit ea2fa56

Browse files
committed
Deprecate the className prop
Users should wrap the `<Markdown>` component inside a `<div>` manually instead. Closes #781
1 parent a27d335 commit ea2fa56

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

changelog.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22

33
All notable changes will be documented in this file.
44

5+
## 9.0.1
6+
7+
### Deprecate `className`
8+
9+
The `className` prop was deprecated.
10+
Not only does the `className` prop add the `className` prop, it also implies a
11+
wrapper `<div>` will be created.
12+
Instead, you should wrap the content in a `<div>` manually.
13+
14+
```jsx
15+
<div className={className}>
16+
<Markdown>
17+
{children}
18+
</Markdown>
19+
</div>
20+
```
21+
522
## 9.0.0 - 2023-09-27
623

724
* [`b67d714`](https://github.com/remarkjs/react-markdown/commit/b67d714)

lib/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ const deprecations = [
116116
id: 'replace-allownode-allowedtypes-and-disallowedtypes',
117117
to: 'allowedElements'
118118
},
119+
{from: 'className', id: 'deprecate-classname'},
119120
{
120121
from: 'disallowedTypes',
121122
id: 'replace-allownode-allowedtypes-and-disallowedtypes',
@@ -266,8 +267,8 @@ export function Markdown(options) {
266267
let remove = allowedElements
267268
? !allowedElements.includes(node.tagName)
268269
: disallowedElements
269-
? disallowedElements.includes(node.tagName)
270-
: false
270+
? disallowedElements.includes(node.tagName)
271+
: false
271272

272273
if (!remove && allowElement && typeof index === 'number') {
273274
remove = !allowElement(node, index, parent)

readme.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,6 @@ Configuration (TypeScript type).
256256
cannot combine w/ `disallowedElements`
257257
* `children` (`string`, optional)
258258
— markdown
259-
* `className` (`string`, optional)
260-
— wrap in a `div` with this class name
261259
* `components` ([`Components`][api-components], optional)
262260
— map tag names to components
263261
* `disallowedElements` (`Array<string>`, default: `[]`)

0 commit comments

Comments
 (0)