React-native-track-player: usePlaybackState is not a fucntion

Created on 13 Apr 2020  路  3Comments  路  Source: react-native-kit/react-native-track-player

Configuration

I am using
"react-native-track-player": "^2.0.0-rc10", with
react-native 0.62.x
Build target: iOS

I am getting this error, I have tried importing it directly from the hook, without it. no luck.

error

Issue

Code

Show us the code you are using

Most helpful comment

@EhteshamAnwar You are using the default export named TrackPlayer. You should use the hook like this. Hope this helps.

import TrackPlayer, { usePlaybackState } from "react-native-track-player";

function MyComponent() {
    const state = usePlaybackState();

    return (
        ...
    )
}

All 3 comments

Looks like you are using the default export. This import should work.

import TrackPlayer, {usePlaybackState} from "react-native-track-player";

@Xammie I have the same import in my code.
import TrackPlayer, { usePlaybackState } from "react-native-track-player";

and this is how I am using usePlaybackState.

const playbackState = TrackPlayer.usePlaybackState();

this works on Android, but this is not working on ios. Please tell me if I am doing something wrong.

@EhteshamAnwar You are using the default export named TrackPlayer. You should use the hook like this. Hope this helps.

import TrackPlayer, { usePlaybackState } from "react-native-track-player";

function MyComponent() {
    const state = usePlaybackState();

    return (
        ...
    )
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

b3rkaydem1r picture b3rkaydem1r  路  3Comments

Sathyanarayan09 picture Sathyanarayan09  路  3Comments

tarahiw picture tarahiw  路  3Comments

mckmarc picture mckmarc  路  4Comments

fabiocosta88 picture fabiocosta88  路  3Comments