From 38d0b0ae01eefa4b2b35a51153fcf42fb024adbc Mon Sep 17 00:00:00 2001 From: Jernej Pregelj Date: Fri, 1 Mar 2019 12:18:48 +0100 Subject: [PATCH] run validation as a callback to first state updates --- src/routes/Publish/index.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/routes/Publish/index.tsx b/src/routes/Publish/index.tsx index 00ad0d9..7109a22 100644 --- a/src/routes/Publish/index.tsx +++ b/src/routes/Publish/index.tsx @@ -118,7 +118,6 @@ class Publish extends Component<{}, PublishState> { } private validateInputs = (name: string, value: any) => { - let { validationStatus } = this.state let hasContent = value.length > 0 // Setting state for all fields @@ -131,7 +130,7 @@ class Publish extends Component<{}, PublishState> { [name]: true } } - })) + }), this.runValidation) } else { this.setState(prevState => ({ validationStatus: { @@ -141,9 +140,12 @@ class Publish extends Component<{}, PublishState> { [name]: false } } - })) + }), this.runValidation) } + } + private runValidation = () => { + let { validationStatus } = this.state // // Step 1 //