5

I need to add link to my logo image.I mean when ever I click my logo image it should redirect to dashboard page.I tried to do it using anchor tag but it is not working properly

 <Header className='header' style={{ position: 'fixed', width: '100%' }}>
      <div className='header-logo' style={{ width: collapsed ? 80 : 200, height: 0 }}>
        {collapsed &&
        <a href="/dashboard">
          <img src={minLogo} alt='Logo' />
        </a>
        }
        { !collapsed &&
          <span>&nbsp;</span>
        }
      </div>
      <Icon
        className="trigger"
        type={collapsed ? 'menu-unfold' : 'menu-fold'}
        onClick={this.toggleSideBar}
      />
      <div style={{ display: 'inline-block', float: 'right' }}>
        <Dropdown overlay={menu} placement="bottomRight">
          <Avatar icon='user' />
        </Dropdown>
      </div>
    </Header>
3
  • are you using react-router ? also what do you mean by its not working properly? do you mean it doesnt navigate properly or is the a tag not rndering? Commented Jul 19, 2019 at 13:59
  • are you getting an error? Commented Jul 19, 2019 at 14:00
  • @akshay kishore I'm using react-router-dom Commented Jul 19, 2019 at 14:00

2 Answers 2

20

Try this

import {  Link } from "react-router-dom";


<Link to="/dashboard">
    <img src={minLogo} alt='Logo' />
</Link>
Sign up to request clarification or add additional context in comments.

1 Comment

happy to help :)
2

User router Link instead of anchor:

    <Link to="/dashboard">
      <img src={minLogo} alt='Logo' />
    </Link>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.