Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
react-quiz-stepper
Advanced tools
Readme
react-quiz-stepper is a react component that gives handy access to quiz data combined with stepper. Behind the scenes it uses context api, so data can be accessed at any level in component tree. Most basic hooks are useQuiz and useStepper.
npm i react-quiz-stepper
Wrap your app inside QuizProvider. (It asks for questions array to initialize with.) and don't forget to import css file.
import React from 'react';
import { QuizProvider } from 'react-quiz-stepper';
import 'react-quiz-stepper/dist/index.css';
const questions = [];
function App() {
return (
<QuizProvider questions={questions}>
{/* rest of your code here */}
</QuizProvider>
);
}
export default App;
Now create your Stepper component and put it inside QuizProvider.
import React from 'react';
import { Stepper, useQuiz } from 'react-quiz-stepper'
function QuizStepperDemo () {
const { state } = useQuiz()
return (
<Stepper>
{state.questions.map((question) => ...)}
{
/**
* map through all questions and render
* appropriate input
* (multi choice or single choice based on question.type)
* only one question will be active depending on the step value
*/
}
</Stepper>
)
}
export default App
const { state, dispatch, getQuestion, getSavedAnswer, generateReport } =
useQuiz();
Name | Type | Description |
---|---|---|
state | QuizState | contains user info, user inputs and questions data. |
dispatch | React.Dispatch | saveUser: (payload: User) => void saveQuestionAnswer: (payload: UserInput) |
getSavedAnswer | func | (questionId) => number or number[] or "" |
getQuestion | func | (questionId: number) => SimplifiedQuestion |
generateReport | func | () => ReportState |
const { step, handleNext, handleBack, goToStep, isLastStep } = useStepper();
Name | Type | Description |
---|---|---|
step | number | Index of the active question. |
handleNext | VoidFunction | Renders next question on screen. |
handleBack | VoidFunction | Renders previous question on screen. |
goToStep | func | (index: number) => void goes to specific question provided. |
isLastStep | boolean | checks if it is a last step. |
It is possible to bind handleBack and handleNext to on click event, to go to next previous and next question respectively.
FAQs
A react component that provides handy access of quiz data combined with a stepper.
The npm package react-quiz-stepper receives a total of 0 weekly downloads. As such, react-quiz-stepper popularity was classified as not popular.
We found that react-quiz-stepper demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.