How to add a copyright symbol in reason-react component?
Asked Answered
D

4

8

I’m new to reason-react. I’m trying to put a copyright symbol in a react-reason component. I've tried

<span >(ReasonReact.stringToElement("&copy;"))</span>

but this doesn’t give me the © symbol.

Danley answered 28/2, 2018 at 22:9 Comment(0)
C
11

It's also possible, and usually simpler, to just use the unicode character:

let copy = ReasonReact.stringToElement({js|\u00a9|js});

// Since ReasonReact 0.7.0 you can use
let copy = React.string({js|\u00a9|js});

Or even shorter:

let copy = [%raw {|'\u00a9'|}];

It's also possible to use unicode characters directly, as long as the whole toolchain supports it properly:

let copy = React.string({js|©|js});

Then for either of these you can now do:

<span> {copy} </span>
Cochineal answered 1/3, 2018 at 0:17 Comment(0)
C
22

Simply put: &copy; if you don't put ; it will not work

Carrick answered 12/1, 2021 at 21:12 Comment(0)
T
15

If you're doing HTML entities like that you have to use the dangerouslySetInnerHTML attribute like so:

<span dangerouslySetInnerHTML={{ "__html": "&copy;" }} />
Tonsorial answered 28/2, 2018 at 22:38 Comment(0)
C
11

It's also possible, and usually simpler, to just use the unicode character:

let copy = ReasonReact.stringToElement({js|\u00a9|js});

// Since ReasonReact 0.7.0 you can use
let copy = React.string({js|\u00a9|js});

Or even shorter:

let copy = [%raw {|'\u00a9'|}];

It's also possible to use unicode characters directly, as long as the whole toolchain supports it properly:

let copy = React.string({js|©|js});

Then for either of these you can now do:

<span> {copy} </span>
Cochineal answered 1/3, 2018 at 0:17 Comment(0)
L
0

To use the use the copy symbol all you have to to is write this ' © '

make sure to write it exactly like that.

Liturgics answered 3/5, 2022 at 20:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.