Answer the question
In order to leave comments, you need to log in
React - how to change isOpen state? Do not mutate state directly. Use setState()?
class Profile extends Component {
state = {
isOpen: false
}
render () {
console.log(this.props.userss[0].name);
(this.props.userss[0].name === "") ? console.log('не судьба') : this.state.isOpen=true;
const body = this.state.isOpen &&
<div>
<div>Name</div>
<h3>
{this.props.userss[0].name}
</h3>
<div>Number</div>
<h3>
{this.props.userss[0].number}
</h3>
<div>Login</div>
<h3>
{this.props.userss[0].login}
</h3>
<div>Karma</div>
<h3>
{this.props.userss[0].karma>0 ? "true" : "false" }
</h3>
<div>Rating</div>
<h3>
{this.props.userss[0].rating}
</h3>
</div>;
return (
<div>
{body}
</div>
)
}
}
export default Profile
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question