1.0.1 • Published 3 years ago

paged-questionnaire v1.0.1

Weekly downloads
7
License
MIT
Repository
github
Last release
3 years ago

paged-questionnaire

Made with create-react-library

NPM JavaScript Style Guide

Install

npm install --save paged-questionnaire

Usage

import React, { Component } from 'react'

import { PagedQuestions } from 'paged-questionnaire'

const QuestionsValues = {...} //check QuestionsValues in ./Example

class Example extends Component {

  const [error, setError] = useState(null)

  const onComplete = (data) => {
    console.log(data)
    //submit to backend (or other process...)
    //after submission, show error by: setError("message")
    setError(null)
    //process results
    //show error setError('an error has occured')
  }

  const questionPageCompleted = (currentPage) => {
    console.log('Finished Question Page #' + currentPage)
  }

  render() {
    return (
      <PagedQuestions
        questions={QuestionsValues}
          onComplete={onComplete}
          onQuestionDone={questionPageCompleted}
          errorMsg={error}
          showProgressBar={true}
      />
    )
  }
}
Parameters
*  onComplete = callback when all forms/pages are completed
*  nextButtonIcon, nextButtonLabel
*  backButtonIcon, backButtonLabel,
*  busy - flag shows spinner/loading icon
*  showProgressBar - show progressbar at the top
*  onQuestionDone - callback every time the user clicks next and answers passed the validations

License

MIT © aman-digtl