I created a react function :
import React, { useContext } from 'react';
import { FeatureFlags } from '../context/FeatureProviderContext';
const UseFeature = ({ name }: { name: string }) => {
const features = useContext(FeatureFlags);
console.log(features?.activeToggles);
if (features === null) {
throw new Error('You must wrap your components in a FeatureProvider.');
}
return Array.isArray(features?.activeToggles)
? features?.activeToggles.includes(name)
: features?.activeToggles[name];
};
export default UseFeature;
My console always returns the following message:
'React' is defined but never used
I think the problem must come from the return but I'm not sure?
Have you ever had this problem ?
CodePudding user response:
Its not a problem, since React 17 you have JSX transform built-in so you don't have to import it.
In your case you don't use JSX at all, anyway you can still use its API, for example:
// Remove named export
import React from 'react';
const useFeature = (args) => {
const features = React.useContext(...);
...
}
