1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 04:46:40 +07:00

#58 using formik at node submit form

This commit is contained in:
Fedor Katurov 2021-03-26 17:52:24 +07:00
parent 4b542e0291
commit b871cc2042
17 changed files with 230 additions and 423 deletions

View file

@ -4,16 +4,18 @@ import styles from './styles.module.scss';
import { Textarea } from '~/components/input/Textarea';
import { path } from 'ramda';
import { NodeEditorProps } from '~/redux/node/types';
import { useNodeFormContext } from '~/utils/hooks/useNodeFormFormik';
type IProps = NodeEditorProps & {};
const TextEditor: FC<IProps> = ({ data, setData }) => {
const setText = useCallback(
(text: string) => setData({ ...data, blocks: [{ type: 'text', text }] }),
[data, setData]
);
const TextEditor: FC<IProps> = () => {
const { values, setFieldValue } = useNodeFormContext();
const text = (path(['blocks', 0, 'text'], data) as string) || '';
const setText = useCallback((text: string) => setFieldValue('blocks', [{ type: 'text', text }]), [
setFieldValue,
]);
const text = (path(['blocks', 0, 'text'], values) as string) || '';
return (
<div className={styles.wrap}>