fix(challenges): Add key prop to root element (#16493)
The key prop was added to solve the issue of the first question being added to subsequent questions Closes #16483
This commit is contained in:
committed by
Stuart Taylor
parent
7e0f3581bf
commit
8ca5575ac5
@ -29,13 +29,15 @@ const mapStateToProps = createSelector(
|
|||||||
(
|
(
|
||||||
{
|
{
|
||||||
description = [],
|
description = [],
|
||||||
title
|
title,
|
||||||
|
dashedName
|
||||||
},
|
},
|
||||||
meta,
|
meta,
|
||||||
currentIndex,
|
currentIndex,
|
||||||
selectedChoice,
|
selectedChoice,
|
||||||
correct
|
correct
|
||||||
) => ({
|
) => ({
|
||||||
|
dashedName,
|
||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
meta,
|
meta,
|
||||||
@ -59,6 +61,7 @@ function mapDispatchToProps(dispatch) {
|
|||||||
const propTypes = {
|
const propTypes = {
|
||||||
correct: PropTypes.number,
|
correct: PropTypes.number,
|
||||||
currentIndex: PropTypes.number,
|
currentIndex: PropTypes.number,
|
||||||
|
dashedName: PropTypes.string,
|
||||||
description: PropTypes.string,
|
description: PropTypes.string,
|
||||||
meta: PropTypes.object,
|
meta: PropTypes.object,
|
||||||
nextQuestion: PropTypes.fun,
|
nextQuestion: PropTypes.fun,
|
||||||
@ -139,8 +142,9 @@ export class QuizChallenge extends PureComponent {
|
|||||||
renderQuiz() {
|
renderQuiz() {
|
||||||
const currentIndex = this.props.currentIndex;
|
const currentIndex = this.props.currentIndex;
|
||||||
const question = this.props.description[currentIndex];
|
const question = this.props.description[currentIndex];
|
||||||
|
const questionKey = this.props.dashedName + currentIndex.toString();
|
||||||
return (
|
return (
|
||||||
<div>
|
<div key={questionKey} >
|
||||||
{this.renderTitle()}
|
{this.renderTitle()}
|
||||||
<Row>
|
<Row>
|
||||||
<Col md={6}>
|
<Col md={6}>
|
||||||
|
Reference in New Issue
Block a user