|
@@ -1,11 +1,14 @@
|
|
import React from "react";
|
|
import React from "react";
|
|
|
|
|
|
class PreRound extends React.Component {
|
|
class PreRound extends React.Component {
|
|
|
|
+ constructor(props) {
|
|
|
|
+ super(props);
|
|
|
|
+ this.textareaRef = React.createRef();
|
|
|
|
+ }
|
|
|
|
+
|
|
copyGameId() {
|
|
copyGameId() {
|
|
- const { gameId } = this.props;
|
|
|
|
- const textarea = this.textarea;
|
|
|
|
- textarea.value = gameId;
|
|
|
|
- textarea.select();
|
|
|
|
|
|
+ const { current } = this.textareaRef;
|
|
|
|
+ current.select();
|
|
document.execCommand("copy");
|
|
document.execCommand("copy");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -19,8 +22,9 @@ class PreRound extends React.Component {
|
|
</p>
|
|
</p>
|
|
<button onClick={onStart}>Start Game</button>
|
|
<button onClick={onStart}>Start Game</button>
|
|
<textarea
|
|
<textarea
|
|
- ref={textarea => this.textarea = textarea}
|
|
|
|
|
|
+ ref={this.textareaRef}
|
|
style={{ position: "absolute", top: "-1000px" }}
|
|
style={{ position: "absolute", top: "-1000px" }}
|
|
|
|
+ value={gameId}
|
|
/>
|
|
/>
|
|
</div>
|
|
</div>
|
|
);
|
|
);
|