Browse Source

Fix CI

main
Dan 7 years ago
parent
commit
3d38ca4724
  1. 15
      examples/uncontrolled-components/input-type-file.js

15
examples/uncontrolled-components/input-type-file.js

@ -1,28 +1,27 @@
class FileInput extends React.Component { class FileInput extends React.Component {
// highlight-range{4}
constructor(props) { constructor(props) {
// highlight-range{3}
super(props); super(props);
this.handleSubmit = this.handleSubmit.bind(this); this.handleSubmit = this.handleSubmit.bind(this);
this.fileInput = React.createRef(); this.fileInput = React.createRef();
} }
// highlight-range{4}
handleSubmit(event) { handleSubmit(event) {
// highlight-range{4}
event.preventDefault(); event.preventDefault();
alert( alert(
`Selected file - ${this.fileInput.current.files[0].name}` `Selected file - ${
this.fileInput.current.files[0].name
}`
); );
} }
render() { render() {
// highlight-range{5}
return ( return (
<form onSubmit={this.handleSubmit}> <form onSubmit={this.handleSubmit}>
<label> <label>
Upload file: Upload file:
{/* highlight-range{1-3} */} <input type="file" ref={this.fileInput} />
<input
type="file"
ref={this.fileInput}
/>
</label> </label>
<br /> <br />
<button type="submit">Submit</button> <button type="submit">Submit</button>

Loading…
Cancel
Save