1.3.9 • Published 3 years ago
react-surveying v1.3.9
React Surveying
React Surveying is a customizable polling component for React applications that allows users to create and participate in polls with various options.
Installation
You can install the React Poll package using npm or yarn:
npm install react-surveyingor
yarn add react-surveyingimport React, { useState } from 'react';
import { ReactSurvey } from './components/ReactSurvey';
interface Answer {
option: string;
votes: number;
}
export const App = () => {
const question = 'What is your favorite color?';
const [vote, setVote] = useState(false);
const [poll, setPoll] = useState({
pollAnswers: [
{ option: 'Red', votes: 19 },
{ option: 'Blue', votes: 0 },
],
});
const handleVote = (voteAnswer: Answer) => {
const { pollAnswers } = poll;
const newPollAnswers = pollAnswers.map((answer) => {
if (answer.option === voteAnswer.option) answer.votes++;
return answer;
});
setVote(true);
setPoll({
pollAnswers: newPollAnswers,
});
};
return <ReactSurvey vote={vote} question={question} answers={poll.pollAnswers} onVote={handleVote} />;
};
export default App;1.3.9
3 years ago
1.3.7
3 years ago
1.3.6
3 years ago
1.3.5
3 years ago
1.3.4
3 years ago
1.3.3
3 years ago
1.3.2
3 years ago
1.3.1
3 years ago
1.2.9
3 years ago
1.2.8
3 years ago
1.2.7
3 years ago
1.2.6
3 years ago
1.2.5
3 years ago
1.2.4
3 years ago
1.2.3
3 years ago
1.2.2
3 years ago
1.2.1
3 years ago
1.1.10
3 years ago
1.1.9
3 years ago
1.1.8
3 years ago
1.1.7
3 years ago
1.1.5
3 years ago
1.1.4
3 years ago
1.1.3
3 years ago
1.1.2
3 years ago
1.1.1
3 years ago
0.1.9
3 years ago
0.1.8
3 years ago
0.1.7
3 years ago
0.1.6
3 years ago
0.1.5
3 years ago