Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: <svg> attribute width: Expected length, "undefined" #115

Closed
Dara-To opened this issue May 28, 2020 · 6 comments
Closed

Error: <svg> attribute width: Expected length, "undefined" #115

Dara-To opened this issue May 28, 2020 · 6 comments

Comments

@Dara-To
Copy link

Dara-To commented May 28, 2020

Not sure what's going on here. I used the same lottie file from another project and same code but got these errors.

I am able to render the animation but keeping errors in the console is not acceptable.

Screen Shot 2020-05-28 at 4 50 15 PM

<Loader width={330} height={400} />

import React from "react"
import Lottie from "rangel-react-lottie"
import styled from "styled-components"

import animationData from "../../lotties/icons/logo-animation.json"

const Loader = props => {
  const { isLoading, width, height } = props

  const defaultOptions = {
    loop: true,
    autoplay: true,
    animationData,
    rendererSettings: {
      preserveAspectRatio: "xMidYMid slice",
    },
  }

  return (
    <Container>
      <Lottie options={defaultOptions} width={width} height={height} isStopped={!isLoading} />
    </Container>
  )
}

export default Loader
@samzmann
Copy link

samzmann commented Jun 4, 2020

For those of you landing here now, this issue is cause by wrongly importing animationData from the json file.

In the README example, replace:

- import * as animationData from './pinjump.json'
+ import animationData from './pinjump.json'

// ...

const defaultOptions = {
  loop: true,
  autoplay: true, 
- animationData: animationData,
+ animationData,
  rendererSettings: {
   preserveAspectRatio: 'xMidYMid slice'
  }
}

@roger-ngx
Copy link

something really fun here is import * as animationData actually working on my web page but not in storybook. so i had to change to import * as animationData

@Monte47
Copy link

Monte47 commented Aug 4, 2021

The above does not help me. This is my full code.

import React, { useEffect } from 'react'
import lottie from 'lottie-web'
import animationData from '../assets/lottie/Icon-heart_green.json'
// import animationData from '../assets/lottie/loading.json'

const Lottie = () => {
  useEffect(() => {
    lottie.loadAnimation({
      container: document.querySelector('#lottie-element'),
      renderer: 'svg',
      loop: true,
      autoplay: true,
      animationData,
      rendererSettings: {
        preserveAspectRatio: 'xMidYMid slice',
      },
    })
  }, [])

  return (
    <div>
      <div style={{ height: 200, width: 200 }} id="lottie-element" />
    </div>
  )
}

error is:
image

when I use the other animation (the one that is currently commented out) it works fine.

@albe68
Copy link

albe68 commented Sep 4, 2023

I know I'm not supposed to talk about other package here . But I got the same error in Razor Pay Package Node implementation.

@ompupul
Copy link

ompupul commented Oct 26, 2023

hy did you solved it????

@JonatasSilva01
Copy link

JonatasSilva01 commented Feb 8, 2024

verifica se os atributos ou as tags estão certas talvez seja algo do em volta do contexto tive um problema semelhante a esse e o que me ajudou foi analisar os atributos que podem ter vindo sem informações

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants