diaporama-react icon indicating copy to clipboard operation
diaporama-react copied to clipboard

You may need an appropriate loader to handle this file type

Open ajainvivek opened this issue 7 years ago • 3 comments

After installing on react-boilerplate. I get this error.

ajainvivek avatar May 19 '17 06:05 ajainvivek

I have this issue too- I'm looking into it now and will post further if I figure it out.

jnelson180 avatar Oct 31 '17 16:10 jnelson180

same issue..

screen shot 2018-03-19 at 10 09 13 pm

solancer avatar Mar 19 '18 16:03 solancer

Had the same issue - I guess problem is inside CRA configs and that Babel doesn't transpile node_modules with JSX code. So I had to get this lib inside my project 'src' - just placed it in some Component. Also You can copy / paste this code rewritten from gre:

import Diaporama from "diaporama";
import {bool, func, object, number} from "prop-types";

function affectProps(obj, props) {
  for (const k in props) {
    if (k !== "onDiaporamaCreated") {
      // blacklisting only for now. We might do whitelist instead ?
      obj[k] = props[k];
    }
  }

  return obj;
}

export class ReactDiaporama extends Component {
  constructor(props) {
    super(props);
    this.container = React.createRef();
  }

  componentDidMount() {
    const {onDiaporamaCreated} = this.props;
    const opts = affectProps({}, this.props);
    this.diaporama = Diaporama(this.container.current, opts);
    if (onDiaporamaCreated) {
      onDiaporamaCreated(this.diaporama);
    }
  }

  componentWillUnmount() {
    this.diaporama.destroy();
  }

  componentWillReceiveProps(props) {
    affectProps(this.diaporama, props);
  }

  shouldComponentUpdate() {
    return false;
  }

  render() {
    return <div ref={this.container} />;
  }
}

ReactDiaporama.propTypes = {
  data: object.isRequired,
  width: number.isRequired,
  height: number.isRequired,
  resolution: number,
  paused: bool,
  loop: bool,
  autoplay: bool,
  currentTime: number,
  playbackRate: number,
  onDiaporamaCreated: func, // callback giving the diaporama instance. use-case: You can bind Events on the diaporama. See "diaporama" documentation.
};

export default ReactDiaporama;

maksym-plotnikov avatar Jul 14 '19 18:07 maksym-plotnikov