-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.js
More file actions
44 lines (39 loc) · 1.2 KB
/
index.js
File metadata and controls
44 lines (39 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import React from 'react';
import ReactDOM from 'react-dom';
import { EurekaForm, Question, Number } from '../../build';
class InputQuestion extends Question {
render() {
const { onChange, type, children } = this.props
return (
<div>
<span>{children}</span>
<input onChange={onChange} type={type}/>
</div>
)
}
}
class ListQuestion extends Question {
render() {
const { options, onChange, children } = this.props
return (
<ul>
<h1>{children}</h1>
{ options.map((opt, i) => (
<li key={i} onClick={() => onChange(opt)}>{opt}</li>
))}
</ul>
)
}
}
const doStuff = (values) => console.log('submitted', values)
const MyForm = ({values = {}}) => (
<EurekaForm onSubmit={doStuff}>
<InputQuestion type='name'>
What's your name ?
</InputQuestion>
<ListQuestion type='country' options={['Argentina', 'Brazil', 'Canada']}>
Hello <b>{values.name}</b>, and your country ?
</ListQuestion>
</EurekaForm>
)
ReactDOM.render(<MyForm />, document.getElementById('root'));