Upgrade to Pro — share decks privately, control downloads, hide ads and more …

20190707Ionic_Meetup.pdf

Yosuke Onoue
July 07, 2019
370

 20190707Ionic_Meetup.pdf

Yosuke Onoue

July 07, 2019
Tweet

Transcript

  1. *OTUBMMBUJPO $ npm init -y $ npm i @ionic/react react

    react-dom \ react-router react-router-dom $ npm i -D @babel/core @babel/preset-react @svgr/webpack \ babel-loader css-loader style-loader url-loader \ webpack webpack-cli webpack-dev-server
  2. XFCQBDLDPOpHKT const path = require('path') const options = { module:

    { rules: [ // write our loader settings here ] }, entry: { bundle: './src/index' }, output: { path: path.join(__dirname, 'public'), filename: '[name].js' }, devServer: { historyApiFallback: true, contentBase: path.join(__dirname, 'public'), port: 8080 }, mode: process.env.NODE_ENV || 'development' } if (process.env.NODE_ENV !== 'production') { Object.assign(options, { devtool: 'inline-source-map' }) } module.exports = options
  3. CBCFM { test: /\.js$/, use: { loader: 'babel-loader', options: {

    presets: ['@babel/preset-react'] } }, include: [path.resolve(__dirname, 'src')] },
  4. -PBEJOH*DPOT { test: /\.svg$/, use: ['@svgr/webpack', 'url-loader'] } TWHS w

    5SBOTGPSN47(TJOUP3FBDUDPNQPOFOUT
 IUUQTHJUIVCDPNTNPPUIDPEFTWHS w VTFEJODSFBUFSFBDUBQQ import React from 'react' import { IonIcon } from '@ionic/react' import { logoTwitter } from 'ionicons/icons' export const IconExample = () => <IonIcon icon={logoTwitter} /> *OZPVSBQQ
  5. )FMMP 8PSME import React from 'react' import { render }

    from 'react-dom' import { IonApp, IonPage, IonHeader, IonToolbar, IonTitle, IonContent } from '@ionic/react' const App = () => { return ( <IonApp> <IonPage> <IonHeader> <IonToolbar> <IonTitle>Title</IonTitle> </IonToolbar> </IonHeader> <IonContent className='ion-padding'> <h1>Hello, Ionic React</h1> </IonContent> </IonPage> </IonApp> ) } render(<App />, document.querySelector('#content'))
  6. 3PVUJOH import React from 'react' import { render } from

    'react-dom' import { Route } from 'react-router' import { IonApp, IonPage, IonReactRouter, IonRouterOutlet } from '@ionic/react' import RootPage from './pages/root' const App = () => { return ( <IonApp> <IonReactRouter> <IonPage> <IonRouterOutlet> <Route path='/' component={RootPage} exact /> </IonRouterOutlet> </IonPage> </IonReactRouter> </IonApp> ) } render(<App />, document.querySelector('#content'))
  7. *PO.PEBM const ModalExample = () => { const [showModal, setShowModal]

    = React.useState(false) return ( <> <IonContent> <IonButton onClick={() => { setShowModal(true) }} > Show Modal </IonButton> </IonContent> <IonModal isOpen={showModal}> <IonPage> <IonHeader> <IonToolbar> <IonTitle>Modal Example</IonTitle> <IonButtons slot='end'> <IonButton onClick={() => { setShowModal(false) }} > Close </IonButton> </IonButtons> </IonToolbar> </IonHeader> <IonContent className='ion-padding'> <p>Modal opened</p> </IonContent> </IonPage> </IonModal> </> ) }
  8. 6TJOH3FEVY import React from 'react' import { render } from

    'react-dom' import { Route, Switch } from 'react-router-dom' import { Provider } from 'react-redux' import { IonApp, IonPage, IonReactRouter } from '@ionic/react' import store from './store' import RootPage from './pages/root' const App = () => { return ( <Provider store={store}> <IonApp> <IonReactRouter> <IonPage> <Switch> <Route path='/' component={RootPage} /> </Switch> </IonPage> </IonReactRouter> </IonApp> </Provider> ) } render(<App />, document.querySelector('#content'))
  9. #VJMEJOHJ04"QQXJUI$BQBDJUPS w IUUQTDBQBDJUPSJPOJDGSBNFXPSLDPNEPDTHFUUJOH TUBSUFE $ npm install --save @capacitor/core @capacitor/cli

    $ npx cap init --web-dir public $ npx cap add ios $ npx cap open ios $ npx webpack --mode production $ npx cap copy 1SFQBSBUJPO 3FCVJME