#How to create a MDX Tab component for Astro with React?
9 messages · Page 1 of 1 (latest)
Please show what you've tried so far. Some short code samples.
Here is the repo that I am testing: https://github.com/tfsomrat/astro-tab-test/
The Tabs and Tab component is here: https://github.com/tfsomrat/astro-tab-test/tree/main/src/layouts/shortcodes
And I call them here: https://raw.githubusercontent.com/tfsomrat/astro-tab-test/main/src/content/pages/elements.mdx
Astro and Tailwind boilerplate. Contribute to tfsomrat/astro-tab-test development by creating an account on GitHub.
Astro and Tailwind boilerplate. Contribute to tfsomrat/astro-tab-test development by creating an account on GitHub.
This is the main function:
function Tabs({ children }) {
let tabArray;
if (Array.isArray(children)) {
tabArray = children;
// console.log(tabArray);
}
console.log(children);
return <div className="relative">tab</div>;
}
export default Tabs;
When I am logging the children, I get an Array, but the problem is, the array replaced with an unreadable object within a second.
First output (that I need) :
[
{
'astro:jsx': true,
type: [Function: Tab],
props: { name: 'Tab 1', children: [Object] },
[Symbol(astro:renderer)]: 'astro:jsx'
},
{
'astro:jsx': true,
type: [Function: Tab],
props: { name: 'Tab 2', children: [Object] },
[Symbol(astro:renderer)]: 'astro:jsx'
},
{
'astro:jsx': true,
type: [Function: Tab],
props: { name: 'Tab 3', children: [Object] },
[Symbol(astro:renderer)]: 'astro:jsx'
}
]
Second Output (that replaced the first output automatically) :
{
'$$typeof': Symbol(react.element),
type: [Function: StaticHtml] {
shouldComponentUpdate: [Function (anonymous)]
},
key: null,
ref: null,
props: {
value: [String (SlotString): '<li class="tab-item my-0 hidden"><p>I am Tab 1</p></li><li class="tab-item my-0 hidden"><p>I am Tab 2</p></li><li class="tab-item my-0 hidden"><p>I am Tab 3</p></li>'] [HTMLString] {
instructions: null,
[Symbol(astro:slot-string)]: true
}
},
_owner: null,
_store: {}
}
Maybe some inspirations here?
https://github.com/JulianCataldo/web-garden/tree/develop/components/Tabs
It's JS free