0

Using .slice inside jsx in create-react-app

I tried to do str.slice(0,5) but it gives me an error "str.slice is not a function". Is there any other way to do this?

6th Jun 2019, 10:16 AM
Shawaine
Shawaine - avatar
2 Réponses
+ 4
Use the substring method for string.
6th Jun 2019, 10:29 AM
Gordon
Gordon - avatar
0
I just needed to str.toString().substr(0,5). Thanks.
6th Jun 2019, 10:55 AM
Shawaine
Shawaine - avatar