Sign in
Log inSign up

Making re-useable component

Tzahi Ben Artzi's photo
Tzahi Ben Artzi
·Nov 9, 2017

I am fairly new to ReactJS

I got a navbar, and I'm trying to make the buttons for it from React so I'll be able to achieve SPA. I am trying to create 1 button class with a constructor so I'll be able to do it for all my buttons.

This is what I'm trying to do:

class Button extends React.Component {
  //insert constructor
  handleClick = () => {
    ReactDOM.render(this.SpecficiInformation, document.getElementById('content'))
  }

  render() {
    return (
      <p onClick={**this**.handleClick}>

      {this.name}
      </p>
    );
  }
}

ReactDOM.render(<Button />, document.getElementById(this.elementid));
Hassle-free blogging platform that developers and teams love.
  • Docs by Hashnode
    New
  • Blogs
  • AI Markdown Editor
  • GraphQL APIs
  • Open source Starter-kit

© Hashnode 2024 — LinearBytes Inc.

Privacy PolicyTermsCode of Conduct