question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

can't use in react

See original GitHub issue

Tell us about your environment win10

  • Browser and Browser Version: chrome 73.0.3683.86
  • After Effects Version:

What did you do? Please explain the steps you took before you encountered the problem.

  1. yarn add lottie-web
import React, { Component } from 'react';
import { connect } from 'dva';
import Lottie from 'lottie-web';

class Home extends Component {
  constructor(props) {
    super(props)
    this.state = {

    }
  }
  componentDidMount(){
    Lottie.loadAnimation({
      container: document.getElementById('svgcontainer'),
      renderer: 'svg',
      loop: true,
      autoplay: true,
      path: './svgjson/data.json',
    })
  }
  render() {

    return (
      <div >
        <div  id='svgcontainer'></div>
      </div>
    )
  }
}
export default Home;

image

What did you expect to happen? show animation in home page What actually happened? Please include as much relevant detail as possible. image

Please provide a download link to the After Effects file that demonstrates the problem. link: https://pan.baidu.com/s/1P8yxcrqmSc1rQ-N_i8VW7g code: rgfy

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:10

github_iconTop GitHub Comments

11reactions
weieskycommented, Jun 10, 2019

You are Chinese, I answer in Chinese:

  1. 百度网盘对我们真的不太友好… pc端竟然强制我安装客户端…
  2. 你的这个问题跟加载过程对json使用的协议有关系,你的服务器没有对json的类型设置返回“Content-Type: application/json;”,我建议你把这类的文件上传到cdn上,我给你一个cdn地址你试试: https://gw.alipayobjects.com/os/finxbff/2bdd4e9f-99e6-45e7-9b78-80ffe5b2c360/data.json 我顺便把你的文件合并成一个,并对体积做了优化: image
2reactions
sergej-scommented, Jun 10, 2019

@weiesky Not only Chinese wants to read the answer.

Read more comments on GitHub >

github_iconTop Results From Across the Web

I can't seem to be able to use hooks in react - Stack Overflow
Problem, can be using different version of react & react-dom dependencies. If you are using react-router-dom and have Routes like this
Read more >
Invalid Hook Call Warning - React
There are three common reasons you might be seeing it: You might have mismatching versions of React and React DOM. You might be...
Read more >
Why hooks are the best thing to happen to React
React hooks have so many benefits and functions they perform, but one of the big ones is to make the React lifecycle methods...
Read more >
React Hook 'useState' cannot be called in class component
The error "React hook 'useState' cannot be called in a class component" occurs when we try to use the useState hook in a...
Read more >
How To Fix The React Hook 'useState' cannot be called in ...
The Solution · Simply swap out useState with setState · Refactor your component into a function component if you specifically want to use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found