Im trying to load a lottie-web animation in my react project but i keep getting this error and cant understand what it means
InvalidStateError: responseText is only available if responseType is '' or 'document'.
Here is my React component below:
import React, { Component } from "react";
import "./Submit.css";
import PropTypes from "prop-types";
import lottie from "lottie-web";
class Submit extends Component {
constructor(props) {
super(props);
}
componentDidMount() {
lottie.loadAnimation({
container: document.getElementById("animation"), // the dom element that will contain the animation
renderer: "svg",
loop: true,
autoplay: true,
path: "../anim/email.json" // the path to the animation json
});
}
render() {
return <div id="animation" />;
}
}
Submit.propTypes = {};
export default Submit;
Any thoughts on what it could be?
path
should be a path lottie can do a network request to to get the JSON, not a filesystem path. Try to serveemail.json
at the root, and just writepath: "email.json"
. – Souse/email.json
and putting the file in my public folder did the trick. i'm assuming it has to be in the public folder to make it accessible for the network request? – Mixiepublic
folder will be served from/
. I think it's just aapp.use(express.static('public'))
under the hood. – Souse