Answer the question
In order to leave comments, you need to log in
How to render another component multiple times on button click?
Good afternoon! Let's say there is a button that, when clicked, will add an Input component to the page! If you write like this:
import React from 'react'
import { Input } from 'InputComponent'
export default class Parent extends React.Component {
state = {
InputCallState: false
}
inputStateHandler = () => {
this.setState({
inputCallState: true
})
}
render() {
return (
<div>
<button onClick={this.inputStateHandler}>Добавить компонент</button>
{this.state.inputCallState ? <Input /> : null}
</div>
)
}
}
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