@kth/kth-node-react-commondeprecated

Common utility functions and components for React-based node-web projects

Usage no npm install needed!

<script type="module">
  import kthKthNodeReactCommon from 'https://cdn.skypack.dev/@kth/kth-node-react-common';
</script>

README

kth-node-react-common alt text

KTH Stockholm has several applications which are based on React and support server-side rendering with Node.js, e.g. some smaller parts of https://www.kth.se. This package contains common utility functions and components used by those applications.

Installation

  • Install the package:

    npm install @kth/kth-node-react-common
    
  • Install the peer-dependencies of the package:

    npm install axios react prop-types
    

How to use

  • Option 1: Import parts of the package and destructure them then:

    // Examples (ES6 style):
    import { Utils, Components, FormComponents, MobxUtils } from '@kth/kth-node-react-common'
    
    const { ensureObject } = Utils
    const { Breadcrumbs, SystemMessage } = Components
    const { useDataBag, Input } = FormComponents
    const { useStore } = MobxUtils
    
    // Examples (CommonJS style):
    const { Utils, Components, FormComponents, MobxUtils } = require('@kth/kth-node-react-common')
    
    const { ensureObject } = Utils
    const { Breadcrumbs, SystemMessage } = Components
    const { useDataBag, Input } = FormComponents
    const { useStore } = MobxUtils
    
  • Option 2: Import sub-directory of the package and destructure them directly:

    // Examples (ES6 style):
    import { ensureObject } from '@kth/kth-node-react-common/utils'
    import { Breadcrumbs, SystemMessage } from '@kth/kth-node-react-common/components'
    import { useDataBag, Input } from '@kth/kth-node-react-common/FormComponents'
    import { useStore } from '@kth/kth-node-react-common/MobxUtils'
    
    // Examples (CommonJS style):
    const { ensureObject } = require('@kth/kth-node-react-common/utils')
    const { Breadcrumbs, SystemMessage } = require('@kth/kth-node-react-common/components')
    const { useDataBag, Input } = require('@kth/kth-node-react-common/FormComponents')
    const { useStore } = require('@kth/kth-node-react-common/MobxUtils')
    
  • Option 3: Import parts of the package, destructure them twice directly:

    This is only possible with CommonJS style imports.

    // Examples (CommonJS style):
    const { ensureObject } = require('@kth/kth-node-react-common').Utils
    const { Breadcrumbs, SystemMessage } = require('@kth/kth-node-react-common').Components
    const { useDataBag, Input } = require('@kth/kth-node-react-common').FormComponents
    const { useStore } = require('@kth/kth-node-react-common').MobxUtils
    

Package content

The different parts of this package are described in detail in the following Markdown files:

  • MobxUtils
  • Other utilities (tbd.)
  • Helper components (tbd.)
  • FormHelper components (tbd.)