New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SPIKE Look at moving away from Redux Form for CMS 6 #1711
Milestone
Comments
There appears to be a lot of specs for JSON Form schema:
Maybe we should look at picking one approach used by someone else instead of maintaining our own. |
Recommendation:
Existing setup - FormSchema
Existing setup - redux form state management:
Existing setup - notable react components are:
Redux-form:
React-final-form:
import { Form, Field } from 'react-final-form'
export function MyForm {
return <Form
onSubmit={onSubmit}
validate={validate}
render={({ handleSubmit }) => (
<form onSubmit={handleSubmit}>
<Field
name="bio"
render={({ input, meta }) => (
<div>
<label>Bio</label>
<textarea {...input} />
{meta.touched && meta.error && <span>{meta.error}</span>}
</div>
)}
/>
// ... React-hook-form:
import { useState } from "react";
import { useForm } from "react-hook-form";
export function MyForm() {
const { register, handleSubmit } = useForm();
const [data, setData] = useState('');
return (
<form onSubmit={handleSubmit((data) => setData(JSON.stringify(data)))}>
<Header />
<input {...register("firstName")} placeholder="First name" />
// ... Formik
import React from 'react';
import { useFormik } from 'formik';
export function MyForm() {
const formik = useFormik({
initialValues: objectOfData,
onSubmit: values => {
alert(JSON.stringify(values, null, 2));
},
});
return (
<form onSubmit={formik.handleSubmit}>
<label htmlFor="firstName">First Name</label>
<input
id="firstName"
type="text"
onChange={formik.handleChange}
value={formik.values.firstName}
/>
// .... |
Spike complete and discussed. Next step is #1747 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Redux Form is no longer in active development.
The maintainer of Redux Form recommend migrating to React Final Form instead.
Redux form is used by our form schema abstraction.
Timebox
Objectives of the SPIKE
Note
This is really about rendering forms. If you can fine a library that comes with its own form schema standard, that would also be acceptable.
The text was updated successfully, but these errors were encountered: