Opening Component on eventKey click React The Next CEO of Stack OverflowTrigger a button click with JavaScript on the Enter key in a text boxLoop inside React JSXreact-router - pass props to handler componentCan you force a React component to rerender without calling setState?What is the difference between using constructor vs getInitialState in React / React Native?What do these three dots in React do?Programmatically navigate using react routerHow to conditionally add attributes to React components?Detect click outside React componentWhat is the difference between React Native and React?

Would a grinding machine be a simple and workable propulsion system for an interplanetary spacecraft?

Point distance program written without a framework

Defamation due to breach of confidentiality

Expressing the idea of having a very busy time

Lucky Feat: How can "more than one creature spend a luck point to influence the outcome of a roll"?

free fall ellipse or parabola?

What happened in Rome, when the western empire "fell"?

How to use ReplaceAll on an expression that contains a rule

What does "shotgun unity" refer to here in this sentence?

Physiological effects of huge anime eyes

How do I fit a non linear curve?

Can you teleport closer to a creature you are Frightened of?

Computationally populating tables with probability data

Reshaping json / reparing json inside shell script (remove trailing comma)

Is there such a thing as a proper verb, like a proper noun?

What are the unusually-enlarged wing sections on this P-38 Lightning?

How did Beeri the Hittite come up with naming his daughter Yehudit?

Which one is the true statement?

Is there a reasonable and studied concept of reduction between regular languages?

Are the names of these months realistic?

What CSS properties can the br tag have?

Film where the government was corrupt with aliens, people sent to kill aliens are given rigged visors not showing the right aliens

Is it okay to majorly distort historical facts while writing a fiction story?

How to get the last not-null value in an ordered column of a huge table?



Opening Component on eventKey click React



The Next CEO of Stack OverflowTrigger a button click with JavaScript on the Enter key in a text boxLoop inside React JSXreact-router - pass props to handler componentCan you force a React component to rerender without calling setState?What is the difference between using constructor vs getInitialState in React / React Native?What do these three dots in React do?Programmatically navigate using react routerHow to conditionally add attributes to React components?Detect click outside React componentWhat is the difference between React Native and React?










0















I'm new to React and I'm trying to implement a SideNav from this page: Rsuite SideNav. Now when I copy all the code from that page I get it working, but I do not understand how to use the 'eventKey'.



I want to open a new Component called Player.js on the right side of the NavBar and I would like to open the same component with each different selection but to give it different values.

I have understood that you can give different values in React by creating a state, filling it up and passing it on.



But where or how can I set what happens when user click on the selections?



Here is the Sidenav code from that page:



class Demo extends React.Component 
constructor()
super();
this.state =
expanded: true,
activeKey: '1'
;
this.handleToggle = this.handleToggle.bind(this);
this.handleSelect = this.handleSelect.bind(this);

handleToggle()
this.setState(
expanded: !this.state.expanded
);

handleSelect(eventKey)
this.setState(
activeKey: eventKey
);

render()
const expanded = this.state;

return (
<div style= width: 250 >
<Toggle onChange=this.handleToggle checked=expanded />
<hr />
<Sidenav
expanded=expanded
defaultOpenKeys=['3', '4']
activeKey=this.state.activeKey
onSelect=this.handleSelect
>
<Sidenav.Body>
<Nav>
<Nav.Item eventKey="1" icon=<Icon icon="dashboard" />>
Dashboard
</Nav.Item>
<Nav.Item eventKey="2" icon=<Icon icon="group" />>
User Group
</Nav.Item>
<Dropdown
placement="rightTop"
eventKey="3"
title="Advanced"
icon=<Icon icon="magic" />
>
<Dropdown.Item eventKey="3-1">Geo</Dropdown.Item>
<Dropdown.Item eventKey="3-2">Devices</Dropdown.Item>
<Dropdown.Item eventKey="3-3">Loyalty</Dropdown.Item>
<Dropdown.Item eventKey="3-4">Visit Depth</Dropdown.Item>
</Dropdown>
<Dropdown
placement="rightTop"
eventKey="4"
title="Settings"
icon=<Icon icon="gear-circle" />
>
<Dropdown.Item eventKey="4-1">Applications</Dropdown.Item>
<Dropdown.Item eventKey="4-2">Channels</Dropdown.Item>
<Dropdown.Item eventKey="4-3">Versions</Dropdown.Item>
<Dropdown.Menu eventKey="4-5" title="Custom Action">
<Dropdown.Item eventKey="4-5-1">Action Name</Dropdown.Item>
<Dropdown.Item eventKey="4-5-2">Action Params</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
</Nav>
</Sidenav.Body>
</Sidenav>
</div>
);



ReactDOM.render(<Demo />);









share|improve this question




























    0















    I'm new to React and I'm trying to implement a SideNav from this page: Rsuite SideNav. Now when I copy all the code from that page I get it working, but I do not understand how to use the 'eventKey'.



    I want to open a new Component called Player.js on the right side of the NavBar and I would like to open the same component with each different selection but to give it different values.

    I have understood that you can give different values in React by creating a state, filling it up and passing it on.



    But where or how can I set what happens when user click on the selections?



    Here is the Sidenav code from that page:



    class Demo extends React.Component 
    constructor()
    super();
    this.state =
    expanded: true,
    activeKey: '1'
    ;
    this.handleToggle = this.handleToggle.bind(this);
    this.handleSelect = this.handleSelect.bind(this);

    handleToggle()
    this.setState(
    expanded: !this.state.expanded
    );

    handleSelect(eventKey)
    this.setState(
    activeKey: eventKey
    );

    render()
    const expanded = this.state;

    return (
    <div style= width: 250 >
    <Toggle onChange=this.handleToggle checked=expanded />
    <hr />
    <Sidenav
    expanded=expanded
    defaultOpenKeys=['3', '4']
    activeKey=this.state.activeKey
    onSelect=this.handleSelect
    >
    <Sidenav.Body>
    <Nav>
    <Nav.Item eventKey="1" icon=<Icon icon="dashboard" />>
    Dashboard
    </Nav.Item>
    <Nav.Item eventKey="2" icon=<Icon icon="group" />>
    User Group
    </Nav.Item>
    <Dropdown
    placement="rightTop"
    eventKey="3"
    title="Advanced"
    icon=<Icon icon="magic" />
    >
    <Dropdown.Item eventKey="3-1">Geo</Dropdown.Item>
    <Dropdown.Item eventKey="3-2">Devices</Dropdown.Item>
    <Dropdown.Item eventKey="3-3">Loyalty</Dropdown.Item>
    <Dropdown.Item eventKey="3-4">Visit Depth</Dropdown.Item>
    </Dropdown>
    <Dropdown
    placement="rightTop"
    eventKey="4"
    title="Settings"
    icon=<Icon icon="gear-circle" />
    >
    <Dropdown.Item eventKey="4-1">Applications</Dropdown.Item>
    <Dropdown.Item eventKey="4-2">Channels</Dropdown.Item>
    <Dropdown.Item eventKey="4-3">Versions</Dropdown.Item>
    <Dropdown.Menu eventKey="4-5" title="Custom Action">
    <Dropdown.Item eventKey="4-5-1">Action Name</Dropdown.Item>
    <Dropdown.Item eventKey="4-5-2">Action Params</Dropdown.Item>
    </Dropdown.Menu>
    </Dropdown>
    </Nav>
    </Sidenav.Body>
    </Sidenav>
    </div>
    );



    ReactDOM.render(<Demo />);









    share|improve this question


























      0












      0








      0








      I'm new to React and I'm trying to implement a SideNav from this page: Rsuite SideNav. Now when I copy all the code from that page I get it working, but I do not understand how to use the 'eventKey'.



      I want to open a new Component called Player.js on the right side of the NavBar and I would like to open the same component with each different selection but to give it different values.

      I have understood that you can give different values in React by creating a state, filling it up and passing it on.



      But where or how can I set what happens when user click on the selections?



      Here is the Sidenav code from that page:



      class Demo extends React.Component 
      constructor()
      super();
      this.state =
      expanded: true,
      activeKey: '1'
      ;
      this.handleToggle = this.handleToggle.bind(this);
      this.handleSelect = this.handleSelect.bind(this);

      handleToggle()
      this.setState(
      expanded: !this.state.expanded
      );

      handleSelect(eventKey)
      this.setState(
      activeKey: eventKey
      );

      render()
      const expanded = this.state;

      return (
      <div style= width: 250 >
      <Toggle onChange=this.handleToggle checked=expanded />
      <hr />
      <Sidenav
      expanded=expanded
      defaultOpenKeys=['3', '4']
      activeKey=this.state.activeKey
      onSelect=this.handleSelect
      >
      <Sidenav.Body>
      <Nav>
      <Nav.Item eventKey="1" icon=<Icon icon="dashboard" />>
      Dashboard
      </Nav.Item>
      <Nav.Item eventKey="2" icon=<Icon icon="group" />>
      User Group
      </Nav.Item>
      <Dropdown
      placement="rightTop"
      eventKey="3"
      title="Advanced"
      icon=<Icon icon="magic" />
      >
      <Dropdown.Item eventKey="3-1">Geo</Dropdown.Item>
      <Dropdown.Item eventKey="3-2">Devices</Dropdown.Item>
      <Dropdown.Item eventKey="3-3">Loyalty</Dropdown.Item>
      <Dropdown.Item eventKey="3-4">Visit Depth</Dropdown.Item>
      </Dropdown>
      <Dropdown
      placement="rightTop"
      eventKey="4"
      title="Settings"
      icon=<Icon icon="gear-circle" />
      >
      <Dropdown.Item eventKey="4-1">Applications</Dropdown.Item>
      <Dropdown.Item eventKey="4-2">Channels</Dropdown.Item>
      <Dropdown.Item eventKey="4-3">Versions</Dropdown.Item>
      <Dropdown.Menu eventKey="4-5" title="Custom Action">
      <Dropdown.Item eventKey="4-5-1">Action Name</Dropdown.Item>
      <Dropdown.Item eventKey="4-5-2">Action Params</Dropdown.Item>
      </Dropdown.Menu>
      </Dropdown>
      </Nav>
      </Sidenav.Body>
      </Sidenav>
      </div>
      );



      ReactDOM.render(<Demo />);









      share|improve this question
















      I'm new to React and I'm trying to implement a SideNav from this page: Rsuite SideNav. Now when I copy all the code from that page I get it working, but I do not understand how to use the 'eventKey'.



      I want to open a new Component called Player.js on the right side of the NavBar and I would like to open the same component with each different selection but to give it different values.

      I have understood that you can give different values in React by creating a state, filling it up and passing it on.



      But where or how can I set what happens when user click on the selections?



      Here is the Sidenav code from that page:



      class Demo extends React.Component 
      constructor()
      super();
      this.state =
      expanded: true,
      activeKey: '1'
      ;
      this.handleToggle = this.handleToggle.bind(this);
      this.handleSelect = this.handleSelect.bind(this);

      handleToggle()
      this.setState(
      expanded: !this.state.expanded
      );

      handleSelect(eventKey)
      this.setState(
      activeKey: eventKey
      );

      render()
      const expanded = this.state;

      return (
      <div style= width: 250 >
      <Toggle onChange=this.handleToggle checked=expanded />
      <hr />
      <Sidenav
      expanded=expanded
      defaultOpenKeys=['3', '4']
      activeKey=this.state.activeKey
      onSelect=this.handleSelect
      >
      <Sidenav.Body>
      <Nav>
      <Nav.Item eventKey="1" icon=<Icon icon="dashboard" />>
      Dashboard
      </Nav.Item>
      <Nav.Item eventKey="2" icon=<Icon icon="group" />>
      User Group
      </Nav.Item>
      <Dropdown
      placement="rightTop"
      eventKey="3"
      title="Advanced"
      icon=<Icon icon="magic" />
      >
      <Dropdown.Item eventKey="3-1">Geo</Dropdown.Item>
      <Dropdown.Item eventKey="3-2">Devices</Dropdown.Item>
      <Dropdown.Item eventKey="3-3">Loyalty</Dropdown.Item>
      <Dropdown.Item eventKey="3-4">Visit Depth</Dropdown.Item>
      </Dropdown>
      <Dropdown
      placement="rightTop"
      eventKey="4"
      title="Settings"
      icon=<Icon icon="gear-circle" />
      >
      <Dropdown.Item eventKey="4-1">Applications</Dropdown.Item>
      <Dropdown.Item eventKey="4-2">Channels</Dropdown.Item>
      <Dropdown.Item eventKey="4-3">Versions</Dropdown.Item>
      <Dropdown.Menu eventKey="4-5" title="Custom Action">
      <Dropdown.Item eventKey="4-5-1">Action Name</Dropdown.Item>
      <Dropdown.Item eventKey="4-5-2">Action Params</Dropdown.Item>
      </Dropdown.Menu>
      </Dropdown>
      </Nav>
      </Sidenav.Body>
      </Sidenav>
      </div>
      );



      ReactDOM.render(<Demo />);






      reactjs onclick components sidenav






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 7 at 20:23







      kataroty

















      asked Mar 7 at 18:18









      katarotykataroty

      187212




      187212






















          0






          active

          oldest

          votes












          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%2f55050403%2fopening-component-on-eventkey-click-react%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          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%2f55050403%2fopening-component-on-eventkey-click-react%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

          Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

          Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

          Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved