Giter VIP home page Giter VIP logo

Comments (5)

samp6 avatar samp6 commented on August 16, 2024

Had an idea immediately after writing this: I changed the file to plain js rather than ts. It compiled without issue; this must be an issue with this component and ts.

from react-sound.

PABlond avatar PABlond commented on August 16, 2024

I am facing the same issue :
Property 'status' does not exist on type 'ComponentClass<ReactSoundProps, any>'
playStatus={status ? Sound.status.PLAYING : Sound.status.PAUSED}

from react-sound.

PABlond avatar PABlond commented on August 16, 2024

I tried several things : I think in nodes_modules/@types/react-sound/index.d.ts, something like this is missing (it resolves this error but I don't really know if it is a good practise):

interface Status {
status: any
}

declare const ReactSound: React.ComponentClass<ReactSoundProps> & Status

from react-sound.

kieran-osgood avatar kieran-osgood commented on August 16, 2024

I don't suppose there was ever a fix/work around for this? I've just run into this issue in v1.2.2 (typescript 3.7.2)

from react-sound.

tmountain avatar tmountain commented on August 16, 2024

I solved this as follows.

import React, { useState } from 'react';
import Sound, { ReactSoundProps } from 'react-sound';
import './App.css';

function App() {
  const [status, setStatus] = useState<ReactSoundProps['playStatus']>('STOPPED');

  function togglePlayStatus() {
    setStatus(status => status === 'STOPPED' ? 'PLAYING' : 'STOPPED')
  }

  function statusLabel(status: ReactSoundProps['playStatus']): string {
    switch(status) {
      case 'STOPPED':
        return 'PLAY';
      case 'PLAYING':
        return 'STOP';
      default:
        return 'STOP';
    }
  }

  return (
    <div className="App">
      <button onClick={(click) => togglePlayStatus()}>{statusLabel(status)}</button>
      <Sound
        url="https://www.learningcontainer.com/wp-content/uploads/2020/02/Kalimba.mp3"
        playStatus={status}
      />
    </div>
  );
}

export default App;

from react-sound.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.