Skip to content

Commit

Permalink
- fixed get deck from state.
Browse files Browse the repository at this point in the history
  • Loading branch information
maxbogus committed Dec 12, 2018
1 parent baf84c6 commit 09c950f
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions components/Quiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {connect} from 'react-redux'
import SubmitBtn from './SubmitBtn'
import {purple, white} from '../utils/colors'
import {clearLocalNotification, setLocalNotification} from '../utils/notifications'
import {getDeck} from "../utils/storage";

class Quiz extends Component {
static navigationOptions = () => {
Expand All @@ -17,8 +16,7 @@ class Quiz extends Component {
state = {
index: 0,
showAnswer: false,
score: 0,
deck: null
score: 0
};

backToDeck = () => {
Expand All @@ -31,9 +29,6 @@ class Quiz extends Component {
componentDidMount() {
clearLocalNotification()
.then(setLocalNotification);
getDeck(this.props.deckId).then((result) => {
this.setState({deck: result})
});
}

countCorrectAnswer = () => {
Expand Down Expand Up @@ -68,13 +63,8 @@ class Quiz extends Component {
};

render() {
const {index, showAnswer, deck} = this.state;

if (!deck) {
return (
<Text> No data </Text>
)
}
const {index, showAnswer} = this.state;
const {deck} = this.props;

const {questions} = deck;

Expand Down Expand Up @@ -164,8 +154,9 @@ function mapStateToProps(state, {navigation}) {
const {deckId} = navigation.state.params;

return {
deckId
deckId,
deck: state[deckId]
}
}

export default connect(mapDispatchToProps, mapStateToProps)(Quiz)
export default connect(mapStateToProps, mapDispatchToProps)(Quiz)

0 comments on commit 09c950f

Please sign in to comment.