Search code examples
reactjsreact-props

Passing props to a component - syntax error


from APP.JS, I am trying to call another component CountryPanel and passing a param to it but getting syntax error. What am I doing wrong?

function App(props) {
  var countryCode = window.prompt("Enter Country Code")
  
  return (
    <div className="App">
      {(countryCode == "gl") ? <InfoPanel /> : <CountryPanel (countryCode = countryCode) />}}

Line 52:62: Parsing error: Unexpected token

50 |
51 |

52 | {(countryCode == "gl") ? : <CountryPanel (countryCode = countryCode) />}} |


Solution

  • the problem is here,

    {(countryCode == "gl") ? <InfoPanel /> : <CountryPanel (countryCode = countryCode) />}}
    

    Why are you using first bracket in here, ??

    <CountryPanel (countryCode = countryCode) />
    

    YOu probably meant something like this,

    <CountryPanel countryCode={countryCode} />