mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-24 20:53:08 +00:00
new entry on self-closing tag
This commit is contained in:
committed by
Connor McSheffrey
parent
aa38740189
commit
9ccee7f475
11
cookbook/cb-04-self-closing-tag tip.md
Normal file
11
cookbook/cb-04-self-closing-tag tip.md
Normal file
@@ -0,0 +1,11 @@
|
||||
---
|
||||
id: self-closing-tag
|
||||
title: Self-Closing Tag
|
||||
layout: docs
|
||||
permalink: inline-styles.html
|
||||
script: "cookbook/inline-styles.js"
|
||||
---
|
||||
|
||||
In JSX, `<MyComponent />` alone is valid while `<MyComponent>` isn't.
|
||||
|
||||
Related: every React component can be self-closing where it makes sense: `<div/>`.
|
||||
16
cookbook/cb-04-self-closing-tag.md
Normal file
16
cookbook/cb-04-self-closing-tag.md
Normal file
@@ -0,0 +1,16 @@
|
||||
---
|
||||
id: self-closing-tag
|
||||
title: Self-Closing Tag
|
||||
layout: docs
|
||||
permalink: inline-styles.html
|
||||
script: "cookbook/inline-styles.js"
|
||||
---
|
||||
|
||||
### Problem
|
||||
You're getting a parsing error (unexpected token) from JSX.
|
||||
|
||||
### Solution
|
||||
One of the reasons might be that you didn't put a `/` for your self-closing tags. `<MyComponent />` is valid while `<MyComponent>` isn't.
|
||||
|
||||
### Discussion
|
||||
Every React component can be self-closing where it makes sense: `<div/>`.
|
||||
Reference in New Issue
Block a user