fix: icônes partage/streaming via contexte au lieu du layout
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
'use client'
|
||||
|
||||
import {createContext, useContext, useState} from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
const CurrentTrackContext = createContext([null, () => {}])
|
||||
|
||||
export function CurrentTrackProvider({children}) {
|
||||
const state = useState(null)
|
||||
|
||||
return (
|
||||
<CurrentTrackContext.Provider value={state}>
|
||||
{children}
|
||||
</CurrentTrackContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
export function useCurrentTrack() {
|
||||
return useContext(CurrentTrackContext)
|
||||
}
|
||||
|
||||
CurrentTrackProvider.propTypes = {
|
||||
children: PropTypes.node.isRequired
|
||||
}
|
||||
Reference in New Issue
Block a user