-
Notifications
You must be signed in to change notification settings - Fork 414
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #413
- Loading branch information
Showing
3 changed files
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Using HTML entities | ||
|
||
React will escape HTML entities (like ` `, `×`) in the text elements. | ||
|
||
You could just use literal character: `×` or unicode code, which is converted to | ||
the character by Cljs compiler: `\u00D7`. | ||
|
||
HTML entities work in React JSX because JSX will unescape the entity code to | ||
literal character. | ||
|
||
You can do the same in ClojureScript by using `goog.string/unescapeEntities`: | ||
|
||
```cljs | ||
(ns example | ||
(:require [goog.string :as gstr])) | ||
|
||
(defn comp [] | ||
[:h1 "Foo" (gstr/unescapeEntities "×")]) | ||
``` | ||
|
||
Note: Yes, this can be inconvenient, but Reagent can't do this automatically as | ||
finding and replacing entities during runtime would be slow. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters