captivationsoftware / react-file-input Goto Github PK
View Code? Open in Web Editor NEW<FileInput /> component for React
License: MIT License
<FileInput /> component for React
License: MIT License
React.createClass is not a function
Hi there!
How can I clear seleted value? I'm tried to set
value={this.state.image}
and then to set it to null, but it doesnt work.
app.js:37554 Uncaught TypeError: React.createClass is not a function
at Object../node_modules/react-file-input/lib/index.js (app.js:37554)
at __webpack_require__ (app.js:20)
at Module../resources/js/components/PageAdd.js (app.js:53894)
at __webpack_require__ (app.js:20)
at Module../resources/js/pages/car/CarAdd.js (app.js:56941)
at __webpack_require__ (app.js:20)
at Module.<anonymous> (app.js:56019)
at Module../resources/js/pages/App.js (app.js:56198)
at __webpack_require__ (app.js:20)
at Object../resources/js/app.js (app.js:52640)
./node_modules/react-file-input/lib/index.js @ app.js:37554
__webpack_require__ @ app.js:20
./resources/js/components/PageAdd.js @ app.js:53894
__webpack_require__ @ app.js:20
./resources/js/pages/car/CarAdd.js @ app.js:56941
__webpack_require__ @ app.js:20
(anonymous) @ app.js:56019
./resources/js/pages/App.js @ app.js:56198
__webpack_require__ @ app.js:20
./resources/js/app.js @ app.js:52640
__webpack_require__ @ app.js:20
0 @ app.js:59904
__webpack_require__ @ app.js:20
(anonymous) @ app.js:84
(anonymous) @ app.js:87
According to the Github and NPM docs, to use this library you should run:
npm install react-file-upload
but should instead say:
npm install react-file-input
Any chances to update to accept React 15?
Hello,
I tried using your plugin and found that the file received by the event handler was a Synthetic event with all its properties set to null. Is a fix in the works? I tried the demo and noticed the same thing happens. Thanks!
A common use case for a file input is to make it hidden and trigger a click on the input from another button. The way this is designed, it is difficult for me to understand how one could possibly do this. I tried giving the component a ref and then running "this.refs.fileImportInput.getDOMNode().click()" but I could not trigger it this way.
First, thank you for making this, it's a very helpful tool.
I'm trying to handle the case where a user:
The second time the same file is selected, the onChange() handler does not fire. This does make sense, because the file technically has not changed.
But is there any way to "reset" the input, so that the same file will trigger some sort of event that I can handle?
I have setting a ref: <FileInput ref="myFile" ... />
followed by calling this.refs.myFile.state.value = '';
in the onChange
function. This clears the string value in the input field, but it does not "reset" the component.
I'm able to click on the input and choose a file but then nothing happens, it seems onChange is never fired. Do you have any idea why ?
<FileInput
name="file"
accept=".jpg"
placeholder="Your image"
className="mdl-textfield__input"
onChange={this.handleChange.bind(this)}
/>
....
handleChange(event) {
this.setState({
'file': event.target.files[0]
})
};
Hey,
Thanks for the package, I am stuck somewhere can you please help me?
I am trying the below piece of code for rendering the component, It is working perfectly fine, I am getting inputs in HTML but nothing is visible in the UI, no text or no button.
<FileInput
name="avatarImage"
accept=".jpg,.jpeg,.png,.gif"
placeholder="Avatar Image"
className="avatar-image"
onChange={event => console.log('Selected file:', event.target.files[0])}
/>
Selecting file again, when it pops up the second time seems to be working.
The same issue is on the demo page.
OSX, Chrome Version 44.0.2403.61 beta (64-bit)
Example:
<input type="file" multiple>
Thank you.
Hi, i want to put an h2 above the input, but the file select only works if i click the h2, not the input itself. When i open the dev tools, it looks like that there are 2 input inside the code , and the one that responsible for selecting file, collides with the h2.
export class InputFile extends Component {
handleChange(event) {
console.log('Selected file:', event.target.files[0]);
}
render(){
return(
<div style={this.props.style}>
{this.props.inputName ? <h2 className='input-desc'>{this.props.inputName}</h2> : null}
<div className="selectFileContainer">
<form>
<FileInput
name="selectFile"
accept=".zip,.doc,.docs,.docx,.xls,.pdf,.xlsx,.jpg,.jpeg,.png"
onChange={this.handleChange}
>
</FileInput>
</form>
</div>
</div>
)
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.