Skip to content

Commit 9789f43

Browse files
2 parents f19608f + 4a9a3e1 commit 9789f43

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

index.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,10 @@
44

55
<button onclick="location.href='lang.html'">Langs</button><br>
66
<a href="Root/OpenCreators/OpenCreators.exe">Télécharger OpenCreators</a>
7+
8+
<div id="like_button_container"></div>
9+
10+
<script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>
11+
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
12+
<!-- Charge notre composant React -->
13+
<script src="like_button.js"></script>

like_button.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict';
2+
3+
const e = React.createElement;
4+
5+
class LikeButton extends React.Component {
6+
constructor(props) {
7+
super(props);
8+
this.state = { liked: false };
9+
}
10+
11+
render() {
12+
if (this.state.liked) {
13+
return 'You liked this.';
14+
}
15+
16+
return e(
17+
'button',
18+
{ onClick: () => this.setState({ liked: true }) },
19+
'Like'
20+
);
21+
}
22+
}
23+
const domContainer = document.querySelector('#like_button_container');
24+
ReactDOM.render(e(LikeButton), domContainer);

0 commit comments

Comments
 (0)