I am encountering an issue when using the following code snippet:
const contextPaneTitleText = useFeature("contextPaneTitleText").asString();
This code is resulting in an error message:
Argument of type '"contextPaneTitleText"' is not assignable to parameter of type 'keyof RemoteConfig'
The problem seems to be related to my useFeature file's implementation. Here is the code snippet:
import * as React from "react";
import { fetchAndActivate, getValue } from "firebase/remote-config";
import { remoteConfig } from "../../firebase";
import type { RemoteConfig } from "../../firebase";
type FeatureName = keyof RemoteConfig;
function useFeature(name: FeatureName) {
async function fetchConfig() {
await fetchAndActivate(remoteConfig);
}
React.useEffect(() => {
void fetchConfig();
}, [name]);
// reenable these to use different remote config settings for stage than for prod
// const flagName = ENV === "stage" ? `stage_${name}` : name;
// return getValue(remoteConfig, flagName);
return getValue(remoteConfig, name);
}
export { useFeature };