import React from 'react'; import {connect} from 'react-redux'; class PreviewDropzone extends React.Component { constructor (props) { super(props); this.state = { previewSource: '', } this.previewFile = this.previewFile.bind(this); } componentDidMount () { console.log('props after mount', this.props); this.previewFile(this.props.file); } previewFile (file) { console.log('previewFile', file) const that = this; if (file.type !== 'video/mp4') { const previewReader = new FileReader(); previewReader.readAsDataURL(file); previewReader.onloadend = function () { that.setState({previewSource: previewReader.result}); }; } else { that.setState({previewSource: '/assets/img/video_thumb_default.png'}); } } render () { return (

Drag & drop image or video here

OR

CHOOSE FILE

publish preview
); } }; const mapStateToProps = state => { return { file: state.file, }; }; export default connect(mapStateToProps, null)(PreviewDropzone);