Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why am I getting error ts(1005) ',' expected

I’m following a tutorial to learn how to create APIs with React Native and I’m getting ts(1005) error. Can someone please help me? I’ve tried other solutions, but still, no success, and the comment section of the tutorial is disabled 🙁

typescript: 4.5.4

Print and the code follows:
Image,
Android Studio View

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

import React, {useState, useEffect} from 'react';
import {Text, View } from 'react-native';
import {css} from './assets/css/Css';
import Page from './views/Page';

export default function App() {

  const [product, setProduct]=useState(initialState:'teste');

  useEffect(effect:()=>{
    setProduct(value:'New')
  });

  return (
    <View style={css.container}>
      <Text>{product}</Text>
      <Page {...props}/>
    </View>
  );
}

>Solution :

You have a syntax errors when you pass your arguments:

useState(initialState:'teste');

Should be:

useState('teste');

And

  useEffect(effect:()=>{
    setProduct(value:'New')
  });

Should be:

  useEffect(()=>{
    setProduct('New')
  });

You do not need to provide a name for function arguments. Just pass them in in the right position and you’re good.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading