From e9fd9ed65a3593220edab299a216456976945ded Mon Sep 17 00:00:00 2001 From: Ilya Azin Date: Sat, 25 Sep 2021 01:03:25 +0300 Subject: [PATCH 1/3] BOX-216: @fix(tags): fix reflect --- .../card/draft/ui/atoms/tag-input.tsx | 2 +- src/features/card/draft/ui/atoms/tags.tsx | 21 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/features/card/draft/ui/atoms/tag-input.tsx b/src/features/card/draft/ui/atoms/tag-input.tsx index d59c32de..20cfadda 100644 --- a/src/features/card/draft/ui/atoms/tag-input.tsx +++ b/src/features/card/draft/ui/atoms/tag-input.tsx @@ -7,7 +7,7 @@ import React, { } from 'react'; import { Button, IconAdd, Input } from '@box/shared/ui'; import { combine } from 'effector'; -import { reflect } from '@effector/reflect'; +import { reflect } from '@effector/reflect/ssr'; import { theme } from '@box/shared/lib/theme'; import { todo } from '@box/shared/lib/todo'; diff --git a/src/features/card/draft/ui/atoms/tags.tsx b/src/features/card/draft/ui/atoms/tags.tsx index 54b0d189..784a4d29 100644 --- a/src/features/card/draft/ui/atoms/tags.tsx +++ b/src/features/card/draft/ui/atoms/tags.tsx @@ -1,11 +1,11 @@ import React from 'react'; import styled from 'styled-components'; import { Chip } from '@box/shared/ui'; -import { reflect } from '@effector/reflect'; +import { reflect } from '@effector/reflect/ssr'; import { theme } from '@box/shared/lib/theme'; +import { useStore } from 'effector-react/ssr'; import * as model from '../../model'; -import { $tags } from '../../model'; /** * Теги для карточки @@ -29,26 +29,27 @@ const TagsContainer = reflect<{ isEmpty: boolean }>({ return {children}; }, bind: { - isEmpty: $tags.map((tags) => !tags.length), + isEmpty: model.$tags.map((tags) => !tags.length), }, }); -const ChipsView = ({ - tags, - onRemove, -}: { - tags: string[]; +interface Props { + // tags: string[]; onRemove: (tag: string) => void; -}) => { +} + +const ChipsView = ({ onRemove }: Props) => { + const tags = useStore(model.$tags); const handleRemove = (tag: string) => () => onRemove(tag); return ( <> - {tags?.map((tag) => ( + {tags.map((tag) => ( ))} ); }; + const Chips = reflect({ view: ChipsView, bind: { From 74530691d63dba9ab530f4a959fa9f2ea0942815 Mon Sep 17 00:00:00 2001 From: Ilya Azin Date: Sat, 25 Sep 2021 01:35:34 +0300 Subject: [PATCH 2/3] BOX-216: @chore(tags): update reflect to 7.0.0 (latest, for fix) --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index e164e295..a8090ec0 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "author": "github.com/cardbox", "dependencies": { "@cardbox/editor": "^0.1.4", - "@effector/reflect": "^0.6.0", + "@effector/reflect": "^7.0.0", "@svgr/webpack": "^5.5.0", "@tippyjs/react": "^4.2.5", "cross-fetch": "^3.0.4", diff --git a/yarn.lock b/yarn.lock index e0f4a181..0079578f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1627,10 +1627,10 @@ resolved "https://registry.yarnpkg.com/@csstools/convert-colors/-/convert-colors-1.4.0.tgz#ad495dc41b12e75d588c6db8b9834f08fa131eb7" integrity sha512-5a6wqoJV/xEdbRNKVo6I4hO3VjyDq//8q2f9I6PBAvMesJHFauXDorcNCsr9RzvsZnaWi5NYCcfyqP1QeFHFbw== -"@effector/reflect@^0.6.0": - version "0.6.0" - resolved "https://registry.yarnpkg.com/@effector/reflect/-/reflect-0.6.0.tgz#208e05b0f696b1cdff6fc9b089616e79c90d4f2a" - integrity sha512-Dp0AldpbbIcLcxWOprRp2BW/1YYtDdK6sMSJpLnzpXuyK0cgzvp7UPwdMCy/W25Viq0um37mJxSOq5/GQJJQng== +"@effector/reflect@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@effector/reflect/-/reflect-7.0.0.tgz#6c451c569133ed00d3cad05d13049663a5712681" + integrity sha512-qK8aLtp5fWJK5LhfA4Z6xSruhWgR1DT6mDG2rlQ3CvxS6YzXF2Shujcq7D3w91yW3R3eiOFurwJVBcBV6SbfXg== "@emotion/is-prop-valid@^0.8.8": version "0.8.8" From 05850248695559595ebf2fa8cb4a75338f4f16da Mon Sep 17 00:00:00 2001 From: Ilya Azin Date: Sat, 25 Sep 2021 01:36:32 +0300 Subject: [PATCH 3/3] BOX-216: @refactor(tags): return back reflect --- src/features/card/draft/ui/atoms/tags.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/features/card/draft/ui/atoms/tags.tsx b/src/features/card/draft/ui/atoms/tags.tsx index 784a4d29..697ac804 100644 --- a/src/features/card/draft/ui/atoms/tags.tsx +++ b/src/features/card/draft/ui/atoms/tags.tsx @@ -3,7 +3,6 @@ import styled from 'styled-components'; import { Chip } from '@box/shared/ui'; import { reflect } from '@effector/reflect/ssr'; import { theme } from '@box/shared/lib/theme'; -import { useStore } from 'effector-react/ssr'; import * as model from '../../model'; @@ -34,12 +33,11 @@ const TagsContainer = reflect<{ isEmpty: boolean }>({ }); interface Props { - // tags: string[]; + tags: string[]; onRemove: (tag: string) => void; } -const ChipsView = ({ onRemove }: Props) => { - const tags = useStore(model.$tags); +const ChipsView = ({ tags, onRemove }: Props) => { const handleRemove = (tag: string) => () => onRemove(tag); return ( <>