Answer the question
In order to leave comments, you need to log in
How to make toogle buttons?
Hello. I have a task to make a content switch inside the component by clicking on the Next / Prev buttons. I wrote a changeContent function for this (you can see it at the link below). On onClick, the changeContent function is called for me. In that function, the following occurs:
componentDidUpdate
componentDidUpdate(prevProps) {
const {
isBlockNavButtons,
params: { id }
} = this.props;
if (this.props.location !== prevProps.location) {
isBlockNavButtons(null, id, "diagnosis");
getQuestionById("diagnostics", "createQuestion", id);
}
}
isBlockNavButtons
is responsible for the disable logic for those buttons. That is, if we have the last or first element, then we block the button we need. changeContent("prev")
, the data at index 0 is pulled up, the Prev button is blocked, everything is as it should be. But now when I click on next, my data changes, but the prev button remains the same disabled
. GIST
JSFIDDLE
Answer the question
In order to leave comments, you need to log in
isBlockNavButtons
is responsible for the disable logic for those buttons. That is, if we have the last or first element, then we block the button we need.
dispatch({
type: `${CREATE_QUESTION}_BLOCK_BUTTON`,
payload: {
blockPreviousButton: elementIndex === 0,
blockNextButton: elementIndex === data.length - 1
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question