{"id":2647,"date":"2022-05-20T13:26:18","date_gmt":"2022-05-20T11:26:18","guid":{"rendered":"https:\/\/ekiwi.de\/?p=2647"},"modified":"2022-05-20T13:26:18","modified_gmt":"2022-05-20T11:26:18","slug":"react-fehlermeldung-bei-link-the-href-attribute-requires-a-valid-value-to-be-accessible","status":"publish","type":"post","link":"https:\/\/ekiwi.de\/index.php\/2647\/react-fehlermeldung-bei-link-the-href-attribute-requires-a-valid-value-to-be-accessible\/","title":{"rendered":"React: Fehlermeldung bei Link  &#8211; The href attribute requires a valid value to be accessible"},"content":{"rendered":"<p>Warning beim Verwenden eines &#8222;a&#8220; Links mit &#8222;onClick&#8220;.<\/p>\n<p><!--more--><\/p>\n<p>In einer React-Anwendung habe ich einen Link mit einem &#8222;onClick&#8220; Ereignis verwendet. Der Link selbst ist leer:<\/p>\n<pre>&lt;a href=&quot;#&quot; onClick={() =&gt; this.handleSidebar(true)}&gt;Details&lt;\/a&gt;<\/pre>\n<p>Allerdings sorgte dies f\u00fcr eine unsch\u00f6ne Warnung:<\/p>\n<blockquote><p>\nThe href attribute requires a valid value to be accessible. Provide a valid, navigable address as the href value. If you cannot provide a valid href, but still need the element to resemble a link, use a button and change it with appropriate styles. Learn more: https:\/\/github.com\/jsx-eslint\/eslint-plugin-jsx-a11y\/blob\/HEAD\/docs\/rules\/anchor-is-valid.md&#8220;,\n<\/p><\/blockquote>\n<p>Die L\u00f6sung ist dem &#8222;#&#8220; ein &#8222;!&#8220; voraus zu stellen:<\/p>\n<pre>&lt;a href=&quot;!#&quot; onClick={() =&gt; this.handleSidebar(true)}&gt;Details&lt;\/a&gt;<\/pre>\n<p>Ergebnis, Warnung weg, Funktion bleibt gleich.<\/p>","protected":false},"excerpt":{"rendered":"<p>Warning beim Verwenden eines &#8222;a&#8220; Links mit &#8222;onClick&#8220;.<\/p>\n","protected":false},"author":1,"featured_media":2260,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[15,13],"tags":[50,561],"class_list":["post-2647","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","category-programmierung","tag-java-script","tag-react"],"_links":{"self":[{"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/posts\/2647","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/comments?post=2647"}],"version-history":[{"count":0,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/posts\/2647\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/media\/2260"}],"wp:attachment":[{"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/media?parent=2647"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/categories?post=2647"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/tags?post=2647"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}