T
T
Trisman2020-05-16 12:50:50
React
Trisman, 2020-05-16 12:50:50

How to change the text of several buttons at once?

https://vk.cc/auaisi

When you click on the sign up button, the send
button appears . It is necessary that when you click on the send button, the sign up button changes the text to you are written down

. For some reason, the text of only one button changes for me.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
hzzzzl, 2020-05-16
@Trisman

handleClickSubmit = () => {
        // this.props.handleFormSubmitted(!this.state.isSubmited)  <- 
        // что-то такое послать в родительский компонент, и там это сохранить в стейт, 
        // в зависимости от этого и менять текст кнопки
        this.setState({
            isSubmited: !this.state.isSubmited,
        });
    }

V
Vladimir, 2020-05-16
@Casufi

The first option is a bidirectional data flow as in the first answer, but if you have 10 - 20 components you will get confused . The
easiest way is to connect any state management
Context API https://reactjs.org/docs/context.html
redux + react redux
https:/ /mobx.js.org/README.html
From the new https://recoiljs.org/
Second, according to the latest style guide, new components should be made functional using hooks, not classes
1) They fit better into React's functional approach, 2) Work better with Fiber

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question