AdonisJS + React Hooks – CRUD API REST #1 Start

AdonisJS

Install

 npm i -g @adonisjs/cli

Create project

adonis new adonis-app

Run server

adonis serve --dev

React JS

Dependencies

npm install path @babel/core @babel/preset-react react babel-loader react-dom --save

Webpack

npm install webpack webpack-cli --global

webpack.config.js

var path = require('path');

module.exports = {
  entry:  './resources/js/app.js',
  output: {
    path: path.resolve(__dirname, 'public/dist/'),
    filename: 'app.js'
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['@babel/preset-react']
          }
        }
      }
    ]
  }
}

resources/js/components/Example.js

import React from 'react';
import ReactDOM from 'react-dom';

function Example() {
    return (
        <h1>I'm an example component!</h1>
    );
}

export default Example;

if (document.getElementById('component-example')) {
    ReactDOM.render(<Example />, document.getElementById('component-example'));
}

resources/js/app.js

require('./components/Example');

resources/views/welcome.edge

  <div id="component-example"></div>
  <script src="dist/app.js"></script>

Run Webpack

webpack --config webpack.config.js
sudo webpack --watch 

Tutorial part

#2 Views component
https://www.tutofox.com/adonisjs/adonisjs-react-hooks-crud-api-rest-1-views-component/
#3 Migration & Model

https://www.tutofox.com/adonisjs/adonisjs-react-hooks-crud-api-rest-3-migration-model/
#4 Create
https://www.tutofox.com/adonisjs/adonisjs-react-hooks-crud-api-rest-4-create/
#5 List
https://www.tutofox.com/adonisjs/adonisjs-react-hooks-crud-api-rest-5-list/
#6 Edit
https://www.tutofox.com/adonisjs/adonisjs-react-hooks-crud-api-rest-6-edit/
#7 Update
https://www.tutofox.com/adonisjs/adonisjs-react-hooks-crud-api-rest-7-update/
#8 Delete
https://www.tutofox.com/adonisjs/adonisjs-react-hooks-crud-api-rest-8-delete/

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *