-I am integrating builder.io with React app created by “npx create-react-app my-app”
-I am following in the tutorial Developer Quickstart - Builder.io where I used the following REACT code in VSCode from the tutorial to include in the React App Index.js.
import { BuilderComponent, builder, useIsPreviewing } from ‘@builder.io/react’;
import { useEffect } from ‘react’;
// Put your API key here
builder.init(a43150d0381141eda278c0c19f6d6cd1)
// set whether you’re using the Visual Editor,
// whether there are changes,
// and render the content if found
export default function CatchAllRoute() {
const isPreviewingInBuilder = useIsPreviewing();
const [notFound, setNotFound] = useState(false);
const [content, setContent] = useState(null);
useEffect(() => {
async fetchContent() {
const content = await builder.get(‘page’, {
url: location.pathname
}).promise();
setContent(content);
setNotFound(!content);
}
}, [location.pathname]);
// if no page is found, return a 404 page
if (notFound && !isPreviewingInBuilder) {
return
}
// return the page when found
return (
<>
{content?.data.title}
{/* Render the Builder page */}
</>
);
}
<
-
the page can not run because what seems to be syntax errors
error1- synch is “Unexpected keyword or identifier”
error2- a missing semicolon “;” after asynh and another one after the curlbrace “{” following asynch in the following part of the code that a consequence of 1st erroruseEffect(() => {
async fetchContent() {
Thanks for your help
-g