Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I am getting an error in App Router. Error: Functions are not valid as a child of Client Components. This may happen if you return children instead of <children /> from render. Or maybe you meant to call this function rather than return it. #8

Open
DaX-523 opened this issue Jul 16, 2024 · 4 comments

Comments

@DaX-523
Copy link

DaX-523 commented Jul 16, 2024

Even when i copy pasted the code i got this error
Error: Functions are not valid as a child of Client Components. This may happen if you return children instead of from render. Or maybe you meant to call this function rather than return it.
<... className=... width="800" height=... center=... zoom=... children={function children}>
Is this related to using App Router???
Because when i cloned the repository it was working fine with pages directory
The issue arises in this snippet

<Map
            className={styles.homeMap}
            width="800"
            height="400"
            center={DEFAULT_CENTER}
            zoom={12}
          >
            {({ TileLayer, Marker, Popup }) => (
              <>
                <TileLayer
                  url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
                  attribution='&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
                />
                <Marker position={DEFAULT_CENTER}>
                  <Popup>
                    A pretty CSS3 popup. <br /> Easily customizable.
                  </Popup>
                </Marker>
              </>
            )}
          </Map>

Any help would be great :)

@KaidiMohammed
Copy link

Even when i copy pasted the code i got this error Error: Functions are not valid as a child of Client Components. This may happen if you return children instead of from render. Or maybe you meant to call this function rather than return it. <... className=... width="800" height=... center=... zoom=... children={function children}> Is this related to using App Router??? Because when i cloned the repository it was working fine with pages directory The issue arises in this snippet

<Map
            className={styles.homeMap}
            width="800"
            height="400"
            center={DEFAULT_CENTER}
            zoom={12}
          >
            {({ TileLayer, Marker, Popup }) => (
              <>
                <TileLayer
                  url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
                  attribution='&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
                />
                <Marker position={DEFAULT_CENTER}>
                  <Popup>
                    A pretty CSS3 popup. <br /> Easily customizable.
                  </Popup>
                </Marker>
              </>
            )}
          </Map>

Any help would be great :)

Hello, I have the same problems, but I think it's related to the Next.js updates, I didn't find a solution for that, but this repo seems working well with the app router https://github.com/detautama/Example-React-Leaftlet-In-Nextjs-13-App-Router

@colbyfayock
Copy link
Owner

Thanks for sharing a potential solution. I'll eventually get to looking at this but would be happy to review a PR if either of you are interested!

@DaX-523
Copy link
Author

DaX-523 commented Jul 20, 2024

Thanks for sharing a potential solution. I'll eventually get to looking at this but would be happy to review a PR if either of you are interested!

Sure, that would be great. I'll be looking right into it.

@KaidiMohammed
Copy link

Thanks for sharing a potential solution. I'll eventually get to looking at this but would be happy to review a PR if either of you are interested!

sure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants