How to import svg into antd -> Icon component



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








2















Hey I am trying to import my own svg into antd -> Icon component
like in the documentation but i got an exception




InvalidCharacterError: Failed to execute 'createElement' on
'Document': The tag name provided
('/static/media/archive-solid.3c305173.svg') is not a valid name.




Im using create react app 2.1.1 and antd version 3.10.3
I would not want to do the create react app eject and i dont access to webpack
any ideas.
that the code:



import React, Component from "react";
import Layout, Menu, Icon from "antd";
import ArchiveSVG from "../../../img/icons/archive-solid.svg";

const Sider = Layout;

class SideBar extends Component
state =
collapsed: false
;

onCollapse = collapsed =>
this.setState( collapsed );
;

render()
return (
<Sider
collapsible
collapsed=this.state.collapsed
onCollapse=this.onCollapse
>
<div className=styles.logo />
<Menu theme="dark" defaultSelectedKeys=["1"] mode="inline">
<Menu.Item key="4">
<Icon component=ArchiveSVG />
<span>Products</span>
</Menu.Item>
</Menu>
</Sider>
);











share|improve this question
























  • Where is archive-solid.svg located? Outside of src/ folder?

    – Alex
    Nov 17 '18 at 2:48











  • have you tried this approach: stackoverflow.com/questions/52344200/…

    – user3006708
    Nov 19 '18 at 15:32

















2















Hey I am trying to import my own svg into antd -> Icon component
like in the documentation but i got an exception




InvalidCharacterError: Failed to execute 'createElement' on
'Document': The tag name provided
('/static/media/archive-solid.3c305173.svg') is not a valid name.




Im using create react app 2.1.1 and antd version 3.10.3
I would not want to do the create react app eject and i dont access to webpack
any ideas.
that the code:



import React, Component from "react";
import Layout, Menu, Icon from "antd";
import ArchiveSVG from "../../../img/icons/archive-solid.svg";

const Sider = Layout;

class SideBar extends Component
state =
collapsed: false
;

onCollapse = collapsed =>
this.setState( collapsed );
;

render()
return (
<Sider
collapsible
collapsed=this.state.collapsed
onCollapse=this.onCollapse
>
<div className=styles.logo />
<Menu theme="dark" defaultSelectedKeys=["1"] mode="inline">
<Menu.Item key="4">
<Icon component=ArchiveSVG />
<span>Products</span>
</Menu.Item>
</Menu>
</Sider>
);











share|improve this question
























  • Where is archive-solid.svg located? Outside of src/ folder?

    – Alex
    Nov 17 '18 at 2:48











  • have you tried this approach: stackoverflow.com/questions/52344200/…

    – user3006708
    Nov 19 '18 at 15:32













2












2








2








Hey I am trying to import my own svg into antd -> Icon component
like in the documentation but i got an exception




InvalidCharacterError: Failed to execute 'createElement' on
'Document': The tag name provided
('/static/media/archive-solid.3c305173.svg') is not a valid name.




Im using create react app 2.1.1 and antd version 3.10.3
I would not want to do the create react app eject and i dont access to webpack
any ideas.
that the code:



import React, Component from "react";
import Layout, Menu, Icon from "antd";
import ArchiveSVG from "../../../img/icons/archive-solid.svg";

const Sider = Layout;

class SideBar extends Component
state =
collapsed: false
;

onCollapse = collapsed =>
this.setState( collapsed );
;

render()
return (
<Sider
collapsible
collapsed=this.state.collapsed
onCollapse=this.onCollapse
>
<div className=styles.logo />
<Menu theme="dark" defaultSelectedKeys=["1"] mode="inline">
<Menu.Item key="4">
<Icon component=ArchiveSVG />
<span>Products</span>
</Menu.Item>
</Menu>
</Sider>
);











share|improve this question
















Hey I am trying to import my own svg into antd -> Icon component
like in the documentation but i got an exception




InvalidCharacterError: Failed to execute 'createElement' on
'Document': The tag name provided
('/static/media/archive-solid.3c305173.svg') is not a valid name.




Im using create react app 2.1.1 and antd version 3.10.3
I would not want to do the create react app eject and i dont access to webpack
any ideas.
that the code:



import React, Component from "react";
import Layout, Menu, Icon from "antd";
import ArchiveSVG from "../../../img/icons/archive-solid.svg";

const Sider = Layout;

class SideBar extends Component
state =
collapsed: false
;

onCollapse = collapsed =>
this.setState( collapsed );
;

render()
return (
<Sider
collapsible
collapsed=this.state.collapsed
onCollapse=this.onCollapse
>
<div className=styles.logo />
<Menu theme="dark" defaultSelectedKeys=["1"] mode="inline">
<Menu.Item key="4">
<Icon component=ArchiveSVG />
<span>Products</span>
</Menu.Item>
</Menu>
</Sider>
);








svg create-react-app antd






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 17 '18 at 2:46









Alex

3,602823




3,602823










asked Nov 15 '18 at 15:25









Haim RaitsevHaim Raitsev

162




162












  • Where is archive-solid.svg located? Outside of src/ folder?

    – Alex
    Nov 17 '18 at 2:48











  • have you tried this approach: stackoverflow.com/questions/52344200/…

    – user3006708
    Nov 19 '18 at 15:32

















  • Where is archive-solid.svg located? Outside of src/ folder?

    – Alex
    Nov 17 '18 at 2:48











  • have you tried this approach: stackoverflow.com/questions/52344200/…

    – user3006708
    Nov 19 '18 at 15:32
















Where is archive-solid.svg located? Outside of src/ folder?

– Alex
Nov 17 '18 at 2:48





Where is archive-solid.svg located? Outside of src/ folder?

– Alex
Nov 17 '18 at 2:48













have you tried this approach: stackoverflow.com/questions/52344200/…

– user3006708
Nov 19 '18 at 15:32





have you tried this approach: stackoverflow.com/questions/52344200/…

– user3006708
Nov 19 '18 at 15:32












1 Answer
1






active

oldest

votes


















0














Simplify your svg and export is as JSX like following



import React from 'react';

export default () => <svg viewBox="0 0 512 512" width="1em" height="1em" fill="currentColor">
<path fill="currentColor" d="M8.309 189.836L184.313 37.851C199.719 24.546 224 35.347 224 56.015v80.053c160.629 1.839 288 34.032 288 186.258 0 61.441-39.581 122.309-83.333 154.132-13.653 9.931-33.111-2.533-28.077-18.631 45.344-145.012-21.507-183.51-176.59-185.742V360c0 20.7-24.3 31.453-39.687 18.164l-176.004-152c-11.071-9.562-11.086-26.753 0-36.328z">
</path>
</svg>


and then use is like



<Icon component=RepySVG />


Please create a code pen for more help.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53322676%2fhow-to-import-svg-into-antd-icon-component%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Simplify your svg and export is as JSX like following



    import React from 'react';

    export default () => <svg viewBox="0 0 512 512" width="1em" height="1em" fill="currentColor">
    <path fill="currentColor" d="M8.309 189.836L184.313 37.851C199.719 24.546 224 35.347 224 56.015v80.053c160.629 1.839 288 34.032 288 186.258 0 61.441-39.581 122.309-83.333 154.132-13.653 9.931-33.111-2.533-28.077-18.631 45.344-145.012-21.507-183.51-176.59-185.742V360c0 20.7-24.3 31.453-39.687 18.164l-176.004-152c-11.071-9.562-11.086-26.753 0-36.328z">
    </path>
    </svg>


    and then use is like



    <Icon component=RepySVG />


    Please create a code pen for more help.






    share|improve this answer



























      0














      Simplify your svg and export is as JSX like following



      import React from 'react';

      export default () => <svg viewBox="0 0 512 512" width="1em" height="1em" fill="currentColor">
      <path fill="currentColor" d="M8.309 189.836L184.313 37.851C199.719 24.546 224 35.347 224 56.015v80.053c160.629 1.839 288 34.032 288 186.258 0 61.441-39.581 122.309-83.333 154.132-13.653 9.931-33.111-2.533-28.077-18.631 45.344-145.012-21.507-183.51-176.59-185.742V360c0 20.7-24.3 31.453-39.687 18.164l-176.004-152c-11.071-9.562-11.086-26.753 0-36.328z">
      </path>
      </svg>


      and then use is like



      <Icon component=RepySVG />


      Please create a code pen for more help.






      share|improve this answer

























        0












        0








        0







        Simplify your svg and export is as JSX like following



        import React from 'react';

        export default () => <svg viewBox="0 0 512 512" width="1em" height="1em" fill="currentColor">
        <path fill="currentColor" d="M8.309 189.836L184.313 37.851C199.719 24.546 224 35.347 224 56.015v80.053c160.629 1.839 288 34.032 288 186.258 0 61.441-39.581 122.309-83.333 154.132-13.653 9.931-33.111-2.533-28.077-18.631 45.344-145.012-21.507-183.51-176.59-185.742V360c0 20.7-24.3 31.453-39.687 18.164l-176.004-152c-11.071-9.562-11.086-26.753 0-36.328z">
        </path>
        </svg>


        and then use is like



        <Icon component=RepySVG />


        Please create a code pen for more help.






        share|improve this answer













        Simplify your svg and export is as JSX like following



        import React from 'react';

        export default () => <svg viewBox="0 0 512 512" width="1em" height="1em" fill="currentColor">
        <path fill="currentColor" d="M8.309 189.836L184.313 37.851C199.719 24.546 224 35.347 224 56.015v80.053c160.629 1.839 288 34.032 288 186.258 0 61.441-39.581 122.309-83.333 154.132-13.653 9.931-33.111-2.533-28.077-18.631 45.344-145.012-21.507-183.51-176.59-185.742V360c0 20.7-24.3 31.453-39.687 18.164l-176.004-152c-11.071-9.562-11.086-26.753 0-36.328z">
        </path>
        </svg>


        and then use is like



        <Icon component=RepySVG />


        Please create a code pen for more help.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 29 at 10:39









        Shreyans ShrivastavShreyans Shrivastav

        1114




        1114





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53322676%2fhow-to-import-svg-into-antd-icon-component%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kleinkühnau

            Makov (Slowakei)

            Deutsches Schauspielhaus