/* --- แบบ class component --- */ import React, {Component} from 'react'; import { Image, View, Text,} from 'react-native'; class CustomCard1 extends Component { render() { return ( hello world ); } } export default CustomCard1; /* --- แบบ function component --- */ import React, {Component} from 'react'; import { View, Text,} from 'react-native'; const CustomCard2 = () => { return ( hello world ); } export default CustomCard2;
import React, {Component} from 'react'; import { Image, View, Text,} from 'react-native'; class CustomCard extends Component { render() { return ( {this.props.title} ); } } export default CustomCard;
import React, {Fragment} from 'react'; import CustomCard from './CustomCard'; const App = () => { let firstImage = { uri: 'https://www.thaiall.com/me/picme.jpg'}; let secondImage = { uri: 'https://www.thaiall.com/me/burin.jpg'}; return ( ); }; export default App;
import React, {Component} from 'react'; import { Image, View, Button, Text, } from 'react-native'; class CustomCard extends Component { constructor(props){ super(props) this.state = {isHidden : false} } showHideText = () => { this.setState({isHidden : !this.state.isHidden}) } render() { return ( {!this.state.isHidden && {this.props.title}} ); } } export default CustomCard;
https://snack.expo.dev/@thaiall/f6feef import React, {Component, Fragment} from 'react' import { Image, View, Button, Text,} from 'react-native' class CustomCard extends Component { constructor(props){ super(props) this.state = {isHidden : false} } showHideText = () => { this.setState({isHidden : !this.state.isHidden}) } render() { return ( {!this.state.isHidden && {this.props.title}} ); } } const App = () => { let firstImage = { uri: 'https://www.thaiall.com/me/picme.jpg'}; let secondImage = { uri: 'https://www.thaiall.com/me/burin.jpg'}; return ( ); }; export default App;
import React, {Component, Fragment} from 'react' import { Image, View, Button, Text,} from 'react-native' class CustomCard extends Component { constructor(props){ super(props) this.state = {isHidden : false} } showHideText = () => { this.setState({isHidden : !this.state.isHidden}) } render() { return ( {!this.state.isHidden && {this.props.title}} ); } } class App extends Component { render() { let firstImage = { uri: 'https://www.thaiall.com/me/picme.jpg'}; let secondImage = { uri: 'https://www.thaiall.com/me/burin.jpg'}; return ( ); }; }; export default App;