13 lines
411 B
TypeScript
13 lines
411 B
TypeScript
import { Features, FeatureType } from '@skolplattformen/api'
|
|
import React from 'react'
|
|
import { FeatureFlagsContext } from '../context/feature/featureContext'
|
|
|
|
export const useFeature = (name: FeatureType) => {
|
|
const features = React.useContext<Features>(FeatureFlagsContext)
|
|
if (features === null) {
|
|
throw new Error('You must wrap your components in a FeatureProvider.')
|
|
}
|
|
|
|
return features[name]
|
|
}
|