Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
149
rated 0 times [  154] [ 5]  / answers: 1 / hits: 40691  / 8 Years ago, fri, december 9, 2016, 12:00:00

I want to delete the whitespaces from the beginning and the end of a string. For example, given a string Test , I would like to receive Test. I have tried JavaScript's methods and also some npm libraries, but they don't seem to work with React Native? Any thoughts?



enter


More From » android

 Answers
16

The problem is in your setEmail call and the ES6 syntax that you are using. When you do:



email => this.setEmail({email})



The transpiler transforms it into the following:



email => this.setEmail({email: email})



Which of course is an object.



Then, inside the function, you are trying to apply the trim function to an object, which of course results in failure. Try this instead:



email => this.setEmail(email)



You can read more on the ES6 syntax for object literals here.


[#59768] Tuesday, December 6, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
byronkodyo

Total Points: 552
Total Questions: 87
Total Answers: 104

Location: Burundi
Member since Sat, Aug 21, 2021
3 Years ago
;