@@ -15,6 +15,7 @@ import {
1515declare module "../../src" {
1616 interface Features {
1717 huddles : { optInCopy : string } ;
18+ "voice-chat" : { optInCopy : string } ;
1819 }
1920}
2021
@@ -164,6 +165,9 @@ function Feedback() {
164165
165166// App.tsx
166167function Demos ( ) {
168+ const [ showVoiceChatOptIn , setShowVoiceChatOptIn ] = useState ( true ) ;
169+ const [ showHuddleOptIn , setShowHuddleOptIn ] = useState ( true ) ;
170+
167171 return (
168172 < main >
169173 < h1 > React SDK</ h1 >
@@ -176,7 +180,14 @@ function Demos() {
176180 < code > optin-huddles IS TRUE</ code > . Hit the checkbox below to opt-in/out
177181 of the feature.
178182 </ div >
179- < FeatureOptIn featureKey = { "huddles" } featureName = { "Huddles" } />
183+ { showHuddleOptIn && < FeatureOptIn featureKey = { "huddles" } /> }
184+ < button onClick = { ( ) => setShowHuddleOptIn ( ( prev ) => ! prev ) } >
185+ Toggle voice chat opt-in
186+ </ button >
187+ { showVoiceChatOptIn && < FeatureOptIn featureKey = { "voice-chat" } /> }
188+ < button onClick = { ( ) => setShowVoiceChatOptIn ( ( prev ) => ! prev ) } >
189+ Toggle voice chat opt-in
190+ </ button >
180191
181192 < UpdateContext />
182193 < Feedback />
@@ -185,27 +196,22 @@ function Demos() {
185196 ) ;
186197}
187198
188- // type KeysOfValue<T, TCondition> = {
189- // [K in keyof T]: T[K] extends TCondition ? K : never;
190- // }[keyof T];
191-
192- // type OptInFeature = KeysOfValue<Features, { optInCopy: any }>;
193-
194199function FeatureOptIn < TKey extends FeatureKey > ( {
195200 featureKey,
196- featureName,
197201} : {
198202 featureKey : TKey ;
199- featureName : string ;
200203} ) {
201204 const updateUser = useUpdateUser ( ) ;
202205 const [ sendingUpdate , setSendingUpdate ] = useState ( false ) ;
203206 const { isEnabled, config } = useFeature ( featureKey ) ;
204207
205208 return (
206209 < div >
207- < label htmlFor = "huddlesOptIn" > Opt-in to { featureName } feature</ label >
208- < span > { config . payload ?. optInCopy ?? "Hit the checkbox to opt-in" } </ span >
210+ < label htmlFor = "huddlesOptIn" >
211+ { config . payload ?. optInCopy ?? "Hit the checkbox to opt-in" } :{ " " }
212+ { featureKey }
213+ </ label >
214+
209215 < input
210216 disabled = { sendingUpdate }
211217 id = "huddlesOptIn"
0 commit comments