Code Monkey home page Code Monkey logo

kotlin-react-example's Introduction

Kotlin/JS React, Redux with thunk and Material UI example App

There is a lack of information about the using Kotlin for Web apps. After spending a lot of hours setting up React in my own Kotlin multiplatform project, I thought I would share the basic setup that I use.

The app uses:

  • Redux for state management and redux-thunk for asynchronous actions
  • redux-devtools for debugging the Redux store
  • React classes and functional components with state hooks
  • Material UI provided by muirwik
  • A custom webpack configuration (webpack.config.js)

The architecture I use is as follows:

  • Container components are the entry points for Redux state and actions
  • Functional components are used for styles and also for local state (state hooks)
  • Redux reducers and its state/actions are placed in one object called slice (something akin to Redux Toolkit)
  • All thunks are defined in a separate class/object (if they use coroutines, the scope can be passed in through the constructor)

To run the app use the standard gradle command browserDevelopmentRun. The app will run on port 8080, but it will not auto open because of the custom webpack config.

./gradlew browserDevelopmentRun

The application in this repository is a collection of information I found about Kotlin/JS in one place. I hope it will help some people with setting up their own React apps in Kotlin.

Here are the resources I used for learning and creating this project:

The one thing that I couldn't get working is the ErrorBoundary caused by the lack of getDerivedStateFromError. If someone knows how to implements this in Kotlin, please feel free to reach out and improve this example. All other feedback is also appreciated.

A more in-depth description and explanation of the project can be found on My Blog

kotlin-react-example's People

Contributors

akjaw avatar

Stargazers

 avatar  avatar

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.