Coder Social home page Coder Social logo

turkmvc / react-webcomponent-poc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from trendyol/react-webcomponent-poc

0.0 2.0 0.0 163 KB

Using Web Components API with React. A POC and a case study.

TypeScript 91.43% HTML 0.77% JavaScript 4.81% CSS 3.00%

react-webcomponent-poc's Introduction

react-webcomponent-poc

This repository demonstrates a simple way of setting up a SPA with React/Redux/RxJS/Typescript. Before adopting a different solution, we were using it to embed our React SPA into a Vue application.

Web Components API was used instead of iframes to re-use existing functionality in the Vue panel with sync calls. When built, this SPA can be used as <seller-store-editor /> inside your HTML page. See development/index.ejs for example.

Summary

Run npm start and go to the URL that is printed to the screen. You will see a page that prints your IP to the screen and refreshes it every 1 minute. This page demonstrates managing side effects with redux-observable. You can use the buttons on the page to change your locale. Or change to the other page where you will see a simple counter with redux implemented.

Features

  • Shadow DOM for CSS encapsulation
  • Redux routing with react-router
  • Exposed as Custom Elements
  • Hook/FormattedMessage based localization
  • Redux with redux-observable for managing side effects
  • Unit tests for side-effects/pure components
  • Environment based configuration
  • Automatic linting with TSLint and Prettier

Structure

.
├── config # environment based configuration files
├── development # webpack config and html file for local development
└── src
    ├── components       # pure components with html/css
    ├── containers       # components connected to redux
    ├── services         # API, Utility services
    ├── store            # redux store registration and root types
    ├── translations     # translation files for different languages
    ├── polyfill.ts      # polyfills for intl
    ├── webcomponent.tsx # rendering SPA to custom element in shadow DOM
    └── register.ts      # entrypoint to expose the webcomponent

Commands

  • npm start starts a local working environment with webpack-dev-server
  • npm run build builds and outputs JS files prepend with PROFILE=dev e.g. to build with different configs
  • npm run test runs all unit tests
  • npm run format formats project source code with tslint and prettier

react-webcomponent-poc's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.