diff --git a/web/components/answers/multiple-choice-answers.tsx b/web/components/answers/multiple-choice-answers.tsx
index 450c221a..69f54648 100644
--- a/web/components/answers/multiple-choice-answers.tsx
+++ b/web/components/answers/multiple-choice-answers.tsx
@@ -1,26 +1,23 @@
import { MAX_ANSWER_LENGTH } from 'common/answer'
-import { useState } from 'react'
import Textarea from 'react-expanding-textarea'
import { XIcon } from '@heroicons/react/solid'
-
import { Col } from '../layout/col'
import { Row } from '../layout/row'
export function MultipleChoiceAnswers(props: {
+ answers: string[]
setAnswers: (answers: string[]) => void
}) {
- const [answers, setInternalAnswers] = useState(['', '', ''])
+ const { answers, setAnswers } = props
const setAnswer = (i: number, answer: string) => {
const newAnswers = setElement(answers, i, answer)
- setInternalAnswers(newAnswers)
- props.setAnswers(newAnswers)
+ setAnswers(newAnswers)
}
const removeAnswer = (i: number) => {
const newAnswers = answers.slice(0, i).concat(answers.slice(i + 1))
- setInternalAnswers(newAnswers)
- props.setAnswers(newAnswers)
+ setAnswers(newAnswers)
}
const addAnswer = () => setAnswer(answers.length, '')
@@ -40,10 +37,10 @@ export function MultipleChoiceAnswers(props: {
/>
{answers.length > 2 && (
)}
diff --git a/web/components/choices-toggle-group.tsx b/web/components/choices-toggle-group.tsx
index 61c4e4fd..1e918eda 100644
--- a/web/components/choices-toggle-group.tsx
+++ b/web/components/choices-toggle-group.tsx
@@ -22,7 +22,10 @@ export function ChoicesToggleGroup(props: {
} = props
return (
diff --git a/web/pages/create.tsx b/web/pages/create.tsx
index 19ab2fe0..3225fb4d 100644
--- a/web/pages/create.tsx
+++ b/web/pages/create.tsx
@@ -120,7 +120,8 @@ export function NewContract(props: {
const [isLogScale, setIsLogScale] = useState(!!params?.isLogScale)
const [initialValueString, setInitialValueString] = useState(initValue)
- const [answers, setAnswers] = useState([]) // for multiple choice
+ // for multiple choice, init to 3 empty answers
+ const [answers, setAnswers] = useState(['', '', ''])
useEffect(() => {
if (groupId)
@@ -285,7 +286,7 @@ export function NewContract(props: {
{outcomeType === 'MULTIPLE_CHOICE' && (
-
+
)}
{outcomeType === 'PSEUDO_NUMERIC' && (
@@ -299,7 +300,7 @@ export function NewContract(props: {
e.stopPropagation()}
onChange={(e) => setMinString(e.target.value)}
@@ -310,7 +311,7 @@ export function NewContract(props: {
/>
e.stopPropagation()}
onChange={(e) => setMaxString(e.target.value)}