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:
parent
4b542e0291
commit
b871cc2042
17 changed files with 230 additions and 423 deletions
|
@ -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}>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue