klummy
12/5/2017 - 10:17 AM

renderField.jsx


const renderField = (field) => {
    switch (field.type) {
    case 'text':
    case 'email':
        return <input {...field} />;
    case 'select':
        return (
            <select>
                {
                    field.options.map(option =>
                        <option key={option.id} >{option.data}</option>)
                }
            </select>
        );
    default:
        console.error('Unsupported type');
        return null;
    }
};