Comments (5)
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.
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.
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.
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.
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)
- onPause does not work on iOS when running in background HOT 1
- Mute feature? HOT 2
- Audio stuck when switching networks
- Please update the yarn and npm packages HOT 1
- No supported file found
- Problem with react-sound with setInterval
- Issue Sith Dynamic Positioning
- How to handle multiple plays of the same sound
- AbortError: The fetching process for the media resource was aborted by the user agent at the user's request.
- External sounds are prevented in background [Mobile Firefox, Mobile Safari]
- Uncaught Error: The error you provided does not contain a stack trace. HOT 1
- 怎么去获取当前播放时间?
- onLoad event is not called after onLoading
- typescript issue with onPlaying callback
- Creating a new v1.2.1 release with recent bugfix in master
- React-sound soundmanager doesnt work with useHistory hook
- Duration in milliseconds
- Could not resolve dependency issue for newer react@ ^17 HOT 1
- Decrease update interval
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-sound.