forked from zoltantothcom/Design-Patterns-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResult.jsx
More file actions
31 lines (25 loc) · 704 Bytes
/
Result.jsx
File metadata and controls
31 lines (25 loc) · 704 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import { connect } from 'react-redux';
import { getAnswers } from '../selectors';
const StyledResult = styled.p`
color: ${props => props.theme.text};
margin: 3rem 0;
text-align: center;
`;
export const Result = ({ answers }) => {
let correct = 0;
answers.map(answer => (answer.correct ? correct++ : null));
return (
<StyledResult>
You got <strong>{correct}</strong> patterns right out of {answers.length}.
</StyledResult>
);
};
Result.propTypes = {
answers: PropTypes.array.isRequired
};
export default connect(state => ({
answers: getAnswers(state)
}))(Result);