File tree Expand file tree Collapse file tree 2 files changed +29
-19
lines changed Expand file tree Collapse file tree 2 files changed +29
-19
lines changed Original file line number Diff line number Diff line change @@ -2,26 +2,9 @@ import onChange from "on-change";
22import * as yup from "yup" ;
33import i18next from "../i18n.js" ;
44
5- import { renderErrors , renderInputValue } from "./view .js" ;
5+ import createState from './state .js' ;
66
7- const object = {
8- inputValue : "" ,
9- rssFeed : [ ] ,
10- errors : null ,
11- } ;
12-
13- const state = onChange ( object , ( path , value ) => {
14- console . log ( `состояние изменено: ${ path } ` , value ) ;
15- if ( path === "rssFeed" ) {
16- console . log ( "rss feed:" , value ) ;
17- }
18- if ( path === "inputValue" ) {
19- renderInputValue ( value ) ;
20- }
21- if ( path === "errors" ) {
22- renderErrors ( value ) ;
23- }
24- } ) ;
7+ const state = createState ( ) ;
258
269const schema = yup
2710 . string ( )
Original file line number Diff line number Diff line change 1+ import onChange from "on-change" ;
2+ import { renderErrors , renderInputValue } from "./view.js" ;
3+
4+ const createState = ( ) => {
5+ const object = {
6+ inputValue : "" ,
7+ rssFeed : [ ] ,
8+ errors : null ,
9+ } ;
10+
11+ const state = onChange ( object , ( path , value ) => {
12+ console . log ( `состояние изменено: ${ path } ` , value ) ;
13+ if ( path === "rssFeed" ) {
14+ console . log ( "rss feed:" , value ) ;
15+ }
16+ if ( path === "inputValue" ) {
17+ renderInputValue ( value ) ;
18+ }
19+ if ( path === "errors" ) {
20+ renderErrors ( value ) ;
21+ }
22+ } ) ;
23+
24+ return state ;
25+ } ;
26+
27+ export default createState ;
You can’t perform that action at this time.
0 commit comments