How to make Link fit Component that its inside of it?
up vote
0
down vote
favorite
What I have:
<div className="flexBox">
<h4>Rampa de Cores</h4>
<Link to={"/new"} className="link">
<CustomButton label="Adicionar" className={"addButton"}/>
</Link>
</div>
And the <CustomButton />
returns
<div>
<button className={this.props.className}>{this.props.label}</button>
</div>
The Problem:
All the area that i marked with a red square is clickable and triggers the <Link />
but I need to make it fit the button area only.
What I tried:
I looked for how to make a div fit it's content, in .link
I have
.link {
display: inline-block;
}
but didn't work.
What i need:
- How to make
<Link />
fit it's content? - Or make a better way of triggering
<Link />
using the button.
javascript css reactjs react-router
add a comment |
up vote
0
down vote
favorite
What I have:
<div className="flexBox">
<h4>Rampa de Cores</h4>
<Link to={"/new"} className="link">
<CustomButton label="Adicionar" className={"addButton"}/>
</Link>
</div>
And the <CustomButton />
returns
<div>
<button className={this.props.className}>{this.props.label}</button>
</div>
The Problem:
All the area that i marked with a red square is clickable and triggers the <Link />
but I need to make it fit the button area only.
What I tried:
I looked for how to make a div fit it's content, in .link
I have
.link {
display: inline-block;
}
but didn't work.
What i need:
- How to make
<Link />
fit it's content? - Or make a better way of triggering
<Link />
using the button.
javascript css reactjs react-router
Buttons are not permitted as children of links.
– Paulie_D
Nov 19 at 11:45
You could tryonClick
with the button.
– MrMaavin
Nov 19 at 11:46
Just replace the link with an onClick in the button. React Router provides props which will let you "push" to a new url
– Charlie
Nov 19 at 11:49
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
What I have:
<div className="flexBox">
<h4>Rampa de Cores</h4>
<Link to={"/new"} className="link">
<CustomButton label="Adicionar" className={"addButton"}/>
</Link>
</div>
And the <CustomButton />
returns
<div>
<button className={this.props.className}>{this.props.label}</button>
</div>
The Problem:
All the area that i marked with a red square is clickable and triggers the <Link />
but I need to make it fit the button area only.
What I tried:
I looked for how to make a div fit it's content, in .link
I have
.link {
display: inline-block;
}
but didn't work.
What i need:
- How to make
<Link />
fit it's content? - Or make a better way of triggering
<Link />
using the button.
javascript css reactjs react-router
What I have:
<div className="flexBox">
<h4>Rampa de Cores</h4>
<Link to={"/new"} className="link">
<CustomButton label="Adicionar" className={"addButton"}/>
</Link>
</div>
And the <CustomButton />
returns
<div>
<button className={this.props.className}>{this.props.label}</button>
</div>
The Problem:
All the area that i marked with a red square is clickable and triggers the <Link />
but I need to make it fit the button area only.
What I tried:
I looked for how to make a div fit it's content, in .link
I have
.link {
display: inline-block;
}
but didn't work.
What i need:
- How to make
<Link />
fit it's content? - Or make a better way of triggering
<Link />
using the button.
javascript css reactjs react-router
javascript css reactjs react-router
asked Nov 19 at 11:43
Vencovsky
386
386
Buttons are not permitted as children of links.
– Paulie_D
Nov 19 at 11:45
You could tryonClick
with the button.
– MrMaavin
Nov 19 at 11:46
Just replace the link with an onClick in the button. React Router provides props which will let you "push" to a new url
– Charlie
Nov 19 at 11:49
add a comment |
Buttons are not permitted as children of links.
– Paulie_D
Nov 19 at 11:45
You could tryonClick
with the button.
– MrMaavin
Nov 19 at 11:46
Just replace the link with an onClick in the button. React Router provides props which will let you "push" to a new url
– Charlie
Nov 19 at 11:49
Buttons are not permitted as children of links.
– Paulie_D
Nov 19 at 11:45
Buttons are not permitted as children of links.
– Paulie_D
Nov 19 at 11:45
You could try
onClick
with the button.– MrMaavin
Nov 19 at 11:46
You could try
onClick
with the button.– MrMaavin
Nov 19 at 11:46
Just replace the link with an onClick in the button. React Router provides props which will let you "push" to a new url
– Charlie
Nov 19 at 11:49
Just replace the link with an onClick in the button. React Router provides props which will let you "push" to a new url
– Charlie
Nov 19 at 11:49
add a comment |
3 Answers
3
active
oldest
votes
up vote
1
down vote
accepted
React Router provides a history prop to components.
You can replace your link and include an onClick in the button.
<div className="flexBox">
<h4>Rampa de Cores</h4>
<CustomButton
onClick={() => this.props.history.push('/new')}
label="Adicionar"
className={"addButton"}
/>
</div>
add a comment |
up vote
1
down vote
You should not use button as a child of Link. Instead, you may use button and trigger a state change or redirection when the button is clicked. If the new route is declared with react-router-dom's Route, you may just use the following code:
down vote
favorite
What I have:
<div className="flexBox">
<h4>Rampa de Cores</h4>
<Link to={"/new"} className="link">
<CustomButton label="Adicionar" className={"addButton"}
onButtonClick={()=>this.props.history.push('/new')}/>
</Link>
</div>
<button
onClick={this.props.onButtonClick}
>{this.props.label}</button>
If your current component is not defined with Route, you must use withRouter
from react-router-dom
to get access to the history prop.
add a comment |
up vote
0
down vote
you can use below flex box styling or else simply make .link display:block; width:100%;
.link{
display:flex;
flex-flow:row wrap;
flex-basis:50%;
min-width:50%;
line-height:normal;
}
As far as height is concerned if the parent .flexbox display property is flex then height will be picked automatically.
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
React Router provides a history prop to components.
You can replace your link and include an onClick in the button.
<div className="flexBox">
<h4>Rampa de Cores</h4>
<CustomButton
onClick={() => this.props.history.push('/new')}
label="Adicionar"
className={"addButton"}
/>
</div>
add a comment |
up vote
1
down vote
accepted
React Router provides a history prop to components.
You can replace your link and include an onClick in the button.
<div className="flexBox">
<h4>Rampa de Cores</h4>
<CustomButton
onClick={() => this.props.history.push('/new')}
label="Adicionar"
className={"addButton"}
/>
</div>
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
React Router provides a history prop to components.
You can replace your link and include an onClick in the button.
<div className="flexBox">
<h4>Rampa de Cores</h4>
<CustomButton
onClick={() => this.props.history.push('/new')}
label="Adicionar"
className={"addButton"}
/>
</div>
React Router provides a history prop to components.
You can replace your link and include an onClick in the button.
<div className="flexBox">
<h4>Rampa de Cores</h4>
<CustomButton
onClick={() => this.props.history.push('/new')}
label="Adicionar"
className={"addButton"}
/>
</div>
answered Nov 19 at 11:54
Charlie
1546
1546
add a comment |
add a comment |
up vote
1
down vote
You should not use button as a child of Link. Instead, you may use button and trigger a state change or redirection when the button is clicked. If the new route is declared with react-router-dom's Route, you may just use the following code:
down vote
favorite
What I have:
<div className="flexBox">
<h4>Rampa de Cores</h4>
<Link to={"/new"} className="link">
<CustomButton label="Adicionar" className={"addButton"}
onButtonClick={()=>this.props.history.push('/new')}/>
</Link>
</div>
<button
onClick={this.props.onButtonClick}
>{this.props.label}</button>
If your current component is not defined with Route, you must use withRouter
from react-router-dom
to get access to the history prop.
add a comment |
up vote
1
down vote
You should not use button as a child of Link. Instead, you may use button and trigger a state change or redirection when the button is clicked. If the new route is declared with react-router-dom's Route, you may just use the following code:
down vote
favorite
What I have:
<div className="flexBox">
<h4>Rampa de Cores</h4>
<Link to={"/new"} className="link">
<CustomButton label="Adicionar" className={"addButton"}
onButtonClick={()=>this.props.history.push('/new')}/>
</Link>
</div>
<button
onClick={this.props.onButtonClick}
>{this.props.label}</button>
If your current component is not defined with Route, you must use withRouter
from react-router-dom
to get access to the history prop.
add a comment |
up vote
1
down vote
up vote
1
down vote
You should not use button as a child of Link. Instead, you may use button and trigger a state change or redirection when the button is clicked. If the new route is declared with react-router-dom's Route, you may just use the following code:
down vote
favorite
What I have:
<div className="flexBox">
<h4>Rampa de Cores</h4>
<Link to={"/new"} className="link">
<CustomButton label="Adicionar" className={"addButton"}
onButtonClick={()=>this.props.history.push('/new')}/>
</Link>
</div>
<button
onClick={this.props.onButtonClick}
>{this.props.label}</button>
If your current component is not defined with Route, you must use withRouter
from react-router-dom
to get access to the history prop.
You should not use button as a child of Link. Instead, you may use button and trigger a state change or redirection when the button is clicked. If the new route is declared with react-router-dom's Route, you may just use the following code:
down vote
favorite
What I have:
<div className="flexBox">
<h4>Rampa de Cores</h4>
<Link to={"/new"} className="link">
<CustomButton label="Adicionar" className={"addButton"}
onButtonClick={()=>this.props.history.push('/new')}/>
</Link>
</div>
<button
onClick={this.props.onButtonClick}
>{this.props.label}</button>
If your current component is not defined with Route, you must use withRouter
from react-router-dom
to get access to the history prop.
edited Nov 19 at 12:08
answered Nov 19 at 11:59
Rohan Dhar
457210
457210
add a comment |
add a comment |
up vote
0
down vote
you can use below flex box styling or else simply make .link display:block; width:100%;
.link{
display:flex;
flex-flow:row wrap;
flex-basis:50%;
min-width:50%;
line-height:normal;
}
As far as height is concerned if the parent .flexbox display property is flex then height will be picked automatically.
add a comment |
up vote
0
down vote
you can use below flex box styling or else simply make .link display:block; width:100%;
.link{
display:flex;
flex-flow:row wrap;
flex-basis:50%;
min-width:50%;
line-height:normal;
}
As far as height is concerned if the parent .flexbox display property is flex then height will be picked automatically.
add a comment |
up vote
0
down vote
up vote
0
down vote
you can use below flex box styling or else simply make .link display:block; width:100%;
.link{
display:flex;
flex-flow:row wrap;
flex-basis:50%;
min-width:50%;
line-height:normal;
}
As far as height is concerned if the parent .flexbox display property is flex then height will be picked automatically.
you can use below flex box styling or else simply make .link display:block; width:100%;
.link{
display:flex;
flex-flow:row wrap;
flex-basis:50%;
min-width:50%;
line-height:normal;
}
As far as height is concerned if the parent .flexbox display property is flex then height will be picked automatically.
answered Nov 19 at 11:52
vssadineni
340110
340110
add a comment |
add a comment |
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%2f53373923%2fhow-to-make-link-fit-component-that-its-inside-of-it%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
Buttons are not permitted as children of links.
– Paulie_D
Nov 19 at 11:45
You could try
onClick
with the button.– MrMaavin
Nov 19 at 11:46
Just replace the link with an onClick in the button. React Router provides props which will let you "push" to a new url
– Charlie
Nov 19 at 11:49