wpengine / faustjs

Faust.js™ - The Headless WordPress Framework
https://faustjs.org
Other
1.44k stars 134 forks source link

CoreButton causes Next.js >14: Invalid `<Link>` with `<a>` child #1935

Closed jan-clockworkwp closed 2 weeks ago

jan-clockworkwp commented 3 months ago

Description

When the CoreButton block is used and the link value is set, Next.js complains about: Invalid <Link> with <a> child. More information about the issue can be found at https://nextjs.org/docs/messages/invalid-new-link-with-extra-anchor.

It's essentially the same issue as mentioned here: https://github.com/wpengine/faustjs/issues/1916. I just want to point out that it is still present and that @faustwp/blocks@4.0.0 could be updated to either add the legacyBehavior flag proposed in the Next.js docs or simply remove the creation of the anchor tag within the CoreButton block. Perhaps it is not safe to assume that Next.js 13 or higher is in use, but even the faust.js example repositories are using Next.js version 14 or higher. If someone chooses to use Next.js version less than 13 with faustjs, they should be aware of the risks and security issues associated with using old packages, and they should probably use @faustwp/blocks package of a version less than 4. The latest @faustwp/blocks package should align with the latest Next.js version and therefore comply with any of the proposed solutions in https://nextjs.org/docs/messages/invalid-new-link-with-extra-anchor.

Thank you for considering my proposal for improvement of @faustwp/blocks package.

Steps to reproduce

  1. Set up faust with block support and next.js version >14
  2. Use CoreBlock in the Gut. editor
  3. Give it some url, in my case (https://example.com)
  4. Save post and visit page on the front.

Additional context

No response

@faustwp/core Version

3.0.3

@faustwp/cli Version

3.0.2

FaustWP Plugin Version

1.3.2

WordPress Version

6.5.5

Additional environment details

@faustwp/blocks": "4.0.0"

Please confirm that you have searched existing issues in the repo.

theodesp commented 2 weeks ago

@jan-clockworkwp we included fixes in the latest @faustwp/blocks package that fixes this issue with latest next.js