millions-author-34878
07/31/2023, 5:02 PMbetter-magician-65629
07/31/2023, 7:33 PMloadFeatures() and where you're setting your attributes and creating the growthbook Context? we want to make sure there isn't a race condition.
one thing i noticed is the casing is different for buttonColor and buttoncolor. at this point we only support all lower-case keys, not sure if that could be related.
can you share the endpoint for the features JSON? if buttonColor isn't on it, it'll always be false, and i imagine that maybe you may be looking for buttoncolor. the key needs to be exact in the JSON.better-magician-65629
07/31/2023, 7:34 PMmillions-author-34878
08/01/2023, 12:08 PMmillions-author-34878
08/01/2023, 12:08 PMconst growthbook = new GrowthBook({
apiHost: "<https://cdn.growthbook.io>",
clientKey: "my-key",
enableDevMode: true,
trackingCallback: (experiment, result) => {
console.log("Viewed Experiment", {
experimentId: experiment.key,
variationId: result.key,
});
},
});
/.../
useEffect(() => {
growthbook.loadFeatures({ autoRefresh: true });
}, []);millions-author-34878
08/01/2023, 12:09 PMmillions-author-34878
08/01/2023, 12:10 PMbetter-magician-65629
08/01/2023, 4:47 PMbuttonColor in the Features section of the app: https://app.growthbook.io/featuresmillions-author-34878
08/01/2023, 5:52 PMmillions-author-34878
08/01/2023, 5:52 PMindex-title feature.better-magician-65629
08/01/2023, 5:54 PMconst newButtonColor = useFeatureIsOn("buttonColor");
create a feature buttoncolor with the string variations there so that it matches your experiment. you should then start to see some variation when changing the attributes idbetter-magician-65629
08/01/2023, 5:55 PMbuttoncolor change your code to:
const newButtonColor = useFeatureIsOn("buttoncolor");
you can also use button-color instead for the feature key but it should be lower casedmillions-author-34878
08/01/2023, 5:58 PMbuttoncolor featuremillions-author-34878
08/01/2023, 5:59 PMmillions-author-34878
08/01/2023, 5:59 PMmillions-author-34878
08/01/2023, 5:59 PMimport React from "react";
import { useFeatureIsOn } from "@growthbook/growthbook-react";
export default function Home() {
const newButtonColor = useFeatureIsOn("buttoncolor"); // Its' my feature
console.log(newButtonColor);
return (
<>
{newButtonColor ? (
<p style={{ background: "red" }}>VERMELHO</p>
) : (
<p style={{ background: "blue" }}>AZUL</p>
)}
</>
);
}millions-author-34878
08/01/2023, 5:59 PMmillions-author-34878
08/01/2023, 6:01 PMmillions-author-34878
08/01/2023, 6:05 PMbetter-magician-65629
08/01/2023, 8:33 PMmillions-author-34878
08/02/2023, 12:11 PMmillions-author-34878
08/02/2023, 12:11 PMbetter-magician-65629
08/02/2023, 4:49 PMbetter-magician-65629
08/02/2023, 4:59 PMid in the targeting attributes. you mention you are reading the device ID from a cookie/data layer, is it possible it's not present when setting the attributes?
if you install the growthbook chrome extension, you can troubleshoot these things more easily. it will show you the features available and the user attributes that are used for targeting. and if all looks ok in the chrome extension, you may have a bug in your UI logic.better-magician-65629
08/02/2023, 5:51 PM