admin管理员组文章数量:1406177
I'm getting mad from that. I would like to get rid of that warning:
index.js:1446 Warning: Received
true
for a non-boolean attributeshow
.If you want to write it to the DOM, pass a string instead: show="true" or show={value.toString()}. in div (created by Tooltip)
I'm making a validation form for registrating users. I show tooltip, when password validation fails - when passwords in two inputs are different.
I have attatchRefs in the constructor:
this.attachRefPass = targetPass => this.setState({ targetPass });
Next, between other begin values in constructor:
this.state = {
[...]
password: "",
password2: "",
showTooltipPass: false,
[...]
}
Validation method:
passwordValidation = () => {
this.setState({
showTooltipPass: this.state.password === this.state.password2
});
};
And the Form and Tooltip ponents:
<Form.Group as={Col} controlId="formGridUsername">
<Form.Label>Username</Form.Label>
<Form.Control
required
name="username"
placeholder="Username"
onChange={this.onChangeUsername}
ref={this.attachRefUser}
/>
<Overlay
target={targetUser}
show={showTooltipUser}
placement="right"
>
{props => (
<Tooltip id="overlay-example" {...props}>
There is one username like that already in the system!
</Tooltip>
)}
</Overlay>
</Form.Group>
The Tooltip is from react-boostrap: /
I'm getting mad from that. I would like to get rid of that warning:
index.js:1446 Warning: Received
true
for a non-boolean attributeshow
.If you want to write it to the DOM, pass a string instead: show="true" or show={value.toString()}. in div (created by Tooltip)
I'm making a validation form for registrating users. I show tooltip, when password validation fails - when passwords in two inputs are different.
I have attatchRefs in the constructor:
this.attachRefPass = targetPass => this.setState({ targetPass });
Next, between other begin values in constructor:
this.state = {
[...]
password: "",
password2: "",
showTooltipPass: false,
[...]
}
Validation method:
passwordValidation = () => {
this.setState({
showTooltipPass: this.state.password === this.state.password2
});
};
And the Form and Tooltip ponents:
<Form.Group as={Col} controlId="formGridUsername">
<Form.Label>Username</Form.Label>
<Form.Control
required
name="username"
placeholder="Username"
onChange={this.onChangeUsername}
ref={this.attachRefUser}
/>
<Overlay
target={targetUser}
show={showTooltipUser}
placement="right"
>
{props => (
<Tooltip id="overlay-example" {...props}>
There is one username like that already in the system!
</Tooltip>
)}
</Overlay>
</Form.Group>
The Tooltip is from react-boostrap: https://react-bootstrap.github.io/ponents/overlays/
Share Improve this question asked Jun 8, 2019 at 12:39 kubwoszkubwosz 1211 silver badge8 bronze badges 2-
It seems like in line
show={showTooltipUser}
yourshowTooltipUser
is a boolean value. Try passing some dummy string instead ofshowTooltipUser
(i:eshow={"lorem"}
) and see if the warning es up or not. – random Commented Jun 8, 2019 at 12:49 - Unluckily it doesnt work, get the same error as I described @helloitsjoe below. It wants a boolean :< – kubwosz Commented Jun 8, 2019 at 14:25
2 Answers
Reset to default 6It is the bug that was fixed that Overlay outputs show
value as Boolean
You may fix the issue localy with overriding show
prop
{props => (
<Tooltip id="overlay-example" {...props} show={props.show.toString()}>
There is one username like that already in the system!
</Tooltip>
)}
You are setting a Boolean value (true
or false
) in state.showTooltipPass
, and passing it to Overlay’s show
prop, which appears to expect a string value (”true”
or ”false”
).
If you pass the value in as show={showTooltipPass.toString()}
, this will convert the boolean to a string in the place you need it to be a string.
版权声明:本文标题:javascript - Warning with React Bootstrap tooltip: Received `true` for a non-boolean attribute `show` - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744322774a2600583.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论