Skip to content

Commit 76d2826

Browse files
committed
Render empty value if vnode is false
Currently returning false will render the string ‘false’ React supports returning false or null from render when not wanting to render anything.
1 parent fd00b37 commit 76d2826

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export default function renderToString(vnode, context, opts, inner, isSvgMode) {
5858
let pretty = opts.pretty,
5959
indentChar = typeof pretty==='string' ? pretty : '\t';
6060

61-
if (vnode==null) {
61+
if (vnode==null || vnode===false) {
6262
return '';
6363
}
6464

test/jsx.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,20 @@ describe('jsx', () => {
125125

126126
it('should render empty resolved children identically to no children', () => {
127127
const Empty = () => null;
128+
const False = () => false;
128129
expect(renderJsx(
129130
<div>
130131
<a />
131132
<b>{null}</b>
132133
<c><Empty /></c>
134+
<d><False /></d>
133135
</div>
134136
)).to.equal(dedent`
135137
<div>
136138
<a></a>
137139
<b></b>
138140
<c></c>
141+
<d></d>
139142
</div>
140143
`);
141144
});

0 commit comments

Comments
 (0)