Answers about react
Questions and answers from the Croct community about react.
Ad blockers are dropping Croct calls from our React SPA, how do people fix it?
a slice of our visitors never fire any calls to Croct. I sat in the network tab on a machine with a blocker on and the requests to the evaluate, track and…
React Router SPA, where should I resolve Croct content so the variant does not flash?
Our app is a React Router SPA with no server rendering at all. When a page loads I see the default hero paint first, and then the personalized one swaps in a…
What is the default content fetch timeout in the React SDK and can I tighten it?
Testing on a throttled connection I noticed a content fetch hang for what felt like several seconds before teh fallback kicked in. I would rather it give up…
Setting custom user attributes from a React component with useCroct
In an onboarding step the user picks their interests and I want to write those onto the profile so later audiences can target them. I already have the values…
Getting useContent to return content in the visitor's current locale
my app already keeps the active language in a context, and useContent always comes back in the same language regardless. I want it to return the localized…
Where in my React tree should I put the CroctProvider?
just installed @croct/plug-react and I am not sure how high up the tree the provider actually needs to be. I have a few routes that read content and one that…
How do I get TypeScript types for the content a slot returns in React?
I am tired of treating slot content as any in my React components. Right now I destructure useContent('home-hero') and TypeScript has no idea what the fields…
useEvaluation for a value, not just a boolean, and a safe default if it fails
Most examples I find use useEvaluation for an on/off flag. I want a component to read an actual value from an evaluation instead, like the visitor's country…
Strapi backend with a plain React SPA, which Croct SDK and how do I avoid the flash?
our content lives in Strapi and the storefront is a plain React app on Vite, no Next anywhere in the stack. i want to add Croct for personalization but i keep…
Moving off a client-side flag tool to the Croct React SDK, how did it actually feel?
we run our experiments through a client-side flag SDK and keep fighting the flash of the wrong variant before the rules load. Every page briefly shows the…
How do I pass my own variables into a slot with useContent in React?
the content a slot returns needs to depend on a value my component already has, like the plan tier or a category. I would rather feed that straight into the…
useContent suspends and blanks my whole page, how do I scope the Suspense boundary?
I have a single <Suspense> boundary wrapping the whole page, and every useContent call inside it suspends the entire view until all of the slots resolve. So…