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?
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
add a comment |
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
add a comment |
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
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
reactjs onclick components sidenav
edited Mar 7 at 20:23
kataroty
asked Mar 7 at 18:18
katarotykataroty
187212
187212
add a comment |
add a comment |
0
active
oldest
votes
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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