I have a custom component that i was trying to bind data to and while i was successfully able to bind data to it, I was immediately getting hydration mismatch errors. Here is the code for the custom component:
import Button from “./button”;
import { getDefaultContent } from “./event.content”;
import Image from “next/image”;
function EventTeaser(props) {
const { propTitle, propImage, propDate, propCode, propRegion, propAddress, propEventType } = props;
let event;
if (!props.event) {
event = getDefaultContent();
} else {
event = props.event;
}
let eventTitle = propTitle ? propTitle : event.title;
let eventImage = propImage ? propImage : event.image;
let eventDate = propDate ? propDate : event.startDate;
let eventCode = propCode ? propCode : event.eventCode;
let eventRegion = propRegion ? propRegion : event.region;
let eventType = propEventType ? propEventType : event.eventType;
const className = props.className ? props.className : “”;
const startDate = new Date(eventDate);
const dateOptions1 = {
weekday: “long”,
year: “numeric”,
month: “short”,
day: “numeric”,
};
const dateOptions2 = {
year: “numeric”,
month: “short”,
day: “numeric”,
};
const localizedDate = startDate.toLocaleDateString(undefined, dateOptions1);
return (
{" "}
{eventTitle}
<Image
src={eventImage}
alt={eventTitle}
width=“540”
height=“350”
style={{ borderRadius: “15%” }}
/>
{localizedDate}
{eventRegion} - {eventType}
<button href={
/events/${eventCode}
}>Learn More
);
}
export default EventTeaser;
Please fill out as many of the following questions as possible so we can help you promptly! If you don’t know how to answer or it does not apply, feel free to remove it or leave it blank.
Builder content link
e.g. Builder.io: Drag & Drop Headless CMS
Builder public api key
go to Builder.io: Drag & Drop Headless CMS and copy your PUBLIC api key
Detailed steps to reproduce the bug
e.g. go to the editor, click the styles tab, try to edit opacity, notice the opacity slider does not work
Screenshots or video link
Screenshots of your issue, or even better a link to a video of what is happening. We love using loom for that sort of thing
Code stack you are integrating Builder with
e.g. NextJS, react, Shopify
Reproducible code example
If you are having integration errors, please link to codesandbox or copy and paste your problematic code here. The more detail the better!