# react-quiz-game

> Beta version

Latest version **1.1.0** (published 2022-10-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-quiz-game
pnpm add react-quiz-game
yarn add react-quiz-game
bun add react-quiz-game
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2022-10-22 |
| First published | 2022-10-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 1 |
| Unpacked size | 117.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Yaundee |
| Maintainers | yaundee |

## Links

- npm: https://www.npmjs.com/package/react-quiz-game
- Repository: https://github.com/TymchukRoman/react-quiz-game
- Homepage: https://github.com/TymchukRoman/react-quiz-game#readme
- Issues: https://github.com/TymchukRoman/react-quiz-game/issues
- npm.io page: https://npm.io/package/react-quiz-game

## Dependencies (1)

- [uniqid](https://npm.io/package/uniqid.md) ^5.4.0

## Recent versions

- 1.1.0 (latest) — 2022-10-22
- 1.0.7 — 2022-10-20
- 1.0.6 — 2022-10-18
- 1.0.4 — 2022-10-14
- 1.0.3 — 2022-10-13
- 1.0.2 — 2022-10-13
- 1.0.1 — 2022-10-13
- 1.0.0 — 2022-10-12

## README

# react-quiz-game 

> Beta version

[![NPM](https://img.shields.io/npm/v/react-quiz-game.svg)](https://www.npmjs.com/package/react-quiz-game) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

## Install

```bash
npm install --save react-quiz-game
```

## Usage

```tsx
import { Quiz } from 'react-quiz-game'

const questions = [
  {
    text: "2 + 4",
    answers: ["4", "6", "9", "10"],
    correctAnswer: "6",
  },
  {
    text: "3 + 2",
    answers: ["3", "5", "2", "1"],
    correctAnswer: "5",
  }
];

class Example extends Component {
  render() {
    return <Quiz 
      questions={questions}
      answersCallback={(quizResult) => { 'Your code here' }
    />
  }
}
```

## Async Quiz

```tsx
import { AsyncQuiz } from 'react-quiz-game'

const questions = [
  {
    id: "1",
    text: "2 + 4",
    answers: [
      { id: "6", label: "6" },
      { id: "2", label: "2" },
      { id: "1", label: "1" },
      { id: "-2", label: "-2" }
    ],
  },
  {
    id: "2",
    text: "10 - 7",
    answers: [
      { id: "3", label: "3" },
      { id: "2", label: "2" },
      { id: "17", label: "17" },
      { id: "0", label: "0" }
    ],
  }
];

const checkAnswer = async (aid, qid) => { //aid - answer id, qid = question id
    return await fetchResult(aid, qid);
    // { 
    //   value: true || false, 
    //   correctValue: { id, label } (optional)
    // }
  }

class Example extends Component {
  render() {
    return <AsyncQuiz 
      questions={questions}
      answersCallback={(quizResult) => { 'Your code here' }
      checkQuestion={checkAnswer}
    />
  }
}
```

## License

MIT © [TymchukRoman](https://github.com/TymchukRoman)

---
_Source: https://npm.io/package/react-quiz-game · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
