jxnblk / jxnblk/macro-components

Failed prop type: Invalid child component `[object Object]`. Must be one of: Cover, Body, Footer

Open
#10 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
482
Forks
13
PR merge metrics
No merged PRs in 30d

Description

I'm using Theme UI with the pragma set in `.babelrc` like this:

```json
{
"presets": [["next/babel", {
"preset-react": {
"pragma": "jsx"
}
}]],
"plugins": [
[
"@emotion/babel-plugin-jsx-pragmatic",
{
"module": "theme-ui",
"import": "jsx",
"export": "jsx"
}
]
]
}
```

and I'm creating the following macro component:

```js
import React from "react";
import Macro from "macro-components";
import Flex from "../Flex";
import Box from "../Box";
import Stack from "../Stack";

const Cover = ({ children }) => (

{children}

);

const Body = ({ children }) => {children};

const Footer = ({ children }) => {children};

const Card = Macro({ Cover, Body, Footer })(
({ Cover, Body, Footer }, props) => (

{Cover}

{Body}
{Footer}


)
);

export default Card;
```

but then I'm trying to use it in the app I see the error:

```
Failed prop type: Invalid child component `[object Object]`. Must be one of: Cover, Body, Footer
```

I'm wondering if this is somehow related...

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the error with the shown .babelrc configuration and Card macro component in the app. Inspect the Macro usage and the child-component validation to determine why the Cover, Body, and Footer values are rejected; done means the example renders without the invalid-child warning and the behavior is covered by an appropriate test.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.