Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
react-mcqview
Advanced tools
A customizable multiple choice question react component that is based on the superflows design language.
A customizable multiple choice question react component that is based on the superflows design language.
npm install --save react-mcqview
Install the dependencies.
npm install --save bootstrap
npm install --save react-bootstrap
npm install --save react-bootstrap-icons
npm install --save react-ui-components-superflows
This package allows you to easily create customizable multiple choice question forms in React. You can either choose a single question component, which is called McqView, or a complete form McqForm. This package also allows conditional rendering, wherein certain questions are displayed based on the answer of previous questions.
import React from 'react';
import { useState, useRef } from 'react';
import { McqView } from 'react-mcqview';
import 'bootstrap/dist/css/bootstrap.min.css';
const App = () => {
// Stores the stringified representation
const [value, setValue] = useState('');
function onChange(value) {
console.log('value changed', value);
}
return (
<McqView
question="Do you love fried noodles?"
answers={[
{ answer: 'Yes', id: 1 },
{ answer: 'No', id: 2 },
{ answer: "Can't Say", id: 3 },
]}
multiSelect={true}
selectedValue={[1, 2]}
setValue={setValue}
onChange={onChange}
/>
);
};
export default App;
A sample formdata is show below in the usage section. Form data is an array of question data. Each question data contains the following
import React from 'react'
import { useState, useRef } from "react";
import { Col, Row, Container } from 'react-bootstrap';
import { McqForm } from 'react-mcqview'
import 'bootstrap/dist/css/bootstrap.min.css';
const App = () => {
// Stores the stringified representation
const [value, setValue] = useState('');
function onSubmit(values) {
console.log('form submitted changed', values);
}
const data = [
{
id: 1,
question: "Do you love fried noodles?",
answers: [
{answer: "Yes", id: 1},
{answer: "No", id: 2},
{answer: "Can't Say", id: 3}
],
multiSelect: true
},
{
id: 2,
condition: {
question: 1, answer: [2]
},
question: "Okay, then do you love fried rice?",
answers: [
{answer: "Yes", id: 1},
{answer: "No", id: 2},
{answer: "Can't Say", id: 3}
],
multiSelect: true
},
{
id: 3,
condition: {
question: 2, answer: [2]
},
question: "What about chicken soup?",
answers: [
{answer: "I love it!", id: 1},
{answer: "Next, please", id: 2},
],
multiSelect: true
}
]
return (
<Container className='mt-5'>
<Row className='justify-content-center'>
<Col sm={12} xs={12} md={6} xxl={6}>
<McqForm
formData={data}
onComplete={(result) => {console.log('result', result);}}
showSubmit={true}
onSubmit={(result) => {console.log('onsubmit result', result);}} />
</Col>
</Row>
</Container>
)
}
export default App
PASS src/index.test.js (15.952s)
----------------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
---|---|---|---|---|---|
All files | 93.86 | 86.49 | 92 | 93.2 | |
src | 0 | 0 | 0 | 0 | |
index.js | 0 | 0 | 0 | 0 | |
src/components | 93.86 | 86.49 | 92 | 93.2 | |
McqForm.js | 91.55 | 86.36 | 87.5 | 90.77 | ... 46,147,148,206 |
McqView.js | 97.67 | 86.67 | 100 | 97.37 | 82 |
---------------- | ---------- | ---------- | ---------- | ---------- | ------------------- |
Test Suites: 1 passed, 1 total | |||||
Tests: 11 passed, 11 total | |||||
Snapshots: 0 total | |||||
Time: 16.743s | |||||
Ran all test suites. |
MIT © superflows-dev
FAQs
A customizable multiple choice question react component that is based on the superflows design language.
The npm package react-mcqview receives a total of 2 weekly downloads. As such, react-mcqview popularity was classified as not popular.
We found that react-mcqview 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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.