if we write jsx syntax in ionic-react what would happen? is state={}
objects and props
are valid in .tsx file. I create front end by using .jsx files instead of .tsx, will it cause trouble in deployment and if it so. how do I overcome that without leaning typescript?
import React, { Component } from "react";
import { IonGrid, IonRow, IonCol, IonButton } from "@ionic/react";
import LocationComp from "../comon/locationComp";
class Tab1_react extends Component {
state = {
province: [{ id: 1, name: "Western province" }],
district: [
{ id: 1, name: "Kaluthara" },
{ id: 2, name: "Colombo" },
{ id: 3, name: "Gampaha" },
],
};
render() {
return (
<IonGrid>
{/* 1 row */}
<IonRow>
<IonCol>
<LocationComp
data={this.state.province}
type="Province"
name="name"
id="id"
/>
</IonCol>
</IonRow>
{/* 2 row */}
<IonRow>
<IonCol>
<LocationComp
data={this.state.district}
type="District"
name="name"
id="id"
/>
</IonCol>
</IonRow>
{/* 3 row */}
<IonRow>
<IonCol>
<LocationComp
data={[{ id: 1, name: "Not Yet" }]}
type="Town"
name="name"
id="id"
/>
</IonCol>
</IonRow>
{/* 4 row */}
<IonRow>
<IonCol>
<IonButton fill="outline" expand="block" color="primary">
Search
</IonButton>
</IonCol>
</IonRow>
</IonGrid>
);
}
}
export default Tab1_react;
I made a react component call locationComp
import React, { Component } from "react";
import {
IonButton,
IonSelect,
IonSelectOption,
IonItem,
IonLabel,
} from "@ionic/react";
class LocationComp extends Component {
state = {};
render() {
const {data,name,id,type} = this.props;
return (
<IonItem>
<IonLabel>{type}</IonLabel>
<IonSelect
//value={gender}
placeholder="Select One"
// onIonChange={(e) => setGender(e.detail.value)}
>
{data.map(e=>(
<IonSelectOption key={e["id"]} value="female">{e["name"]}</IonSelectOption>
))}
</IonSelect>
</IonItem>
);
}
}
export default LocationComp;