Repository navigation
Replies: 4 comments 13 replies
You should use Next.js version 16. Next handles the React bundled version automatically, you don't need to worry about it. onClick={() => toggleAccordion({provider.id}) }That is not valid, JSX or JavaScript. You want to do this instead: onClick={() => toggleAccordion(provider.id) }Also, for React-Bootstrap’s accordion, make sure you use <AccordionItem key={provider.id} eventKey={String(provider.id)}>
<AccordionHeader>
{provider.name} {provider.description}
</AccordionHeader>
<AccordionBody>
BODY
</AccordionBody>
</AccordionItem>React-Bootstrap can handle the open/close state for you here, so you probably do not need the custom |
This comment was marked as low quality.
This comment was marked as low quality.
|
The syntax error is caused by passing an object Here’s the corrected line (and a small tweak to keep the open state per item): <AccordionHeader
as="h2"
className="accordion-toggle"
onClick={() => toggleAccordion(provider.id)}
eventKey={provider.id}
data-toggle="collapse"
aria-controls="collapse-text"
aria-expanded={selectedId === provider.id}
>
{provider.name} {provider.description}
</AccordionHeader>And adjust the toggle function to work with the id directly: function toggleAccordion(currentId: typeof provider.id) {
setSelectedId(selectedId === currentId ? null : currentId);
}Make sure |
|
That was it! I commented-out globals.css in the root layout.tsx and BODY is now rendered and doesn't disappear. What I did was comment-out the import of globals.css in the root layout.tsx. Refreshing the instruments page resulted in BODY being rendered and not disappearing. I've confirmed I have the tailwind.css working as I've now added some more tailwind styling to the instruments again and everything is working correctly. My guess is the bootstrap.min.css didn't get correctly loaded until I took (briefly) tailwind out of the mix. I'll mark this thread as answered and get back to reading more of the docs. Thanks so much for all the help. I must say I'm quite impressed by the Next/React framework. Next/React will reduce our current 2000 line HTML template down to < 100 lines. Very nice. BTW no LLMs were used, I am just reading the Next and React docs, the couple of books I already have and websites that have examples of Accordions. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary
I have a backend application in Flask-AppBuilder and am starting to add a frontend using Next.js 14.2.35 & React 18.3.1
I've got the endpoint ,called from the Next.js frontend, returning the data I want and am now populating an Accordion.
The goal is to have the data returned from Flask rendered by the frontend as a set of 4 nested accordions. I am only at the first level of the Accordions.
However, I am getting a synax error on the onClick action
Here's the error message from eslint:
`/Users/emansky/Codes/PythonScripts/VSO_MVC/Py312/vso4/frontend-n14-r18/vso2/src/components/Accordion.tsx
29:88 error Parsing error: ',' expected
✖ 1 problem (1 error, 0 warnings)`
The line in the component Accordion.tsx where I think the error is :
<AccordionHeader as='h2' className="accordion-toggle" onClick={() => toggleAccordion({provider.id}) } eventkey={provider.id} data-toggle="collapse" aria-controls="collapse-text" aria-expanded={open}>I'm new to Next.js and React and Typescript. I'm stuck trying to get the onClick working.
I get the expected list of 29 AccordionItems but clicking on any one of them does nothing.
Any tips to resolve this syntax error would be greatly appreciated!
Additional information
where the variable {data} is the data returned from Flask.
This component is called from page.tsx:
Example
No response
All reactions