1.0.0 • Published 7 years ago

react-isomorphic-loader v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

react-isomorphic-loader

react-isomorphic-loader's purpose is to load frontend libraries only in browser for react isomorphic apps

This is a higher order component ("HOC"). It's an advanced pattern used in React that lets you reuse code logic, it can be summarized as a component factory. It improves isolation, interoperability and maintainability of your code base.

Installation

npm i --save react-isomorphic-loader

Properties

ParameterTypeRequiredDefault valueDescription
librariesstring|string[]yesundefinedIt represents a path or a list of paths to frontend libraries.
strictboolnotrueIf false children are rendered even if libraries aren't loaded. truechildren are rendered only if libraries are loaded

Usage

For one library

<IsomorphicLoader libraries="path/to/some/library/that/need/browser/globals">
  {(myLibraryThatNeedBrowserGlobals) => (<Child />)}
</IsomorphicLoader>

For multiple library

<IsomorphicLoader libraries={[
    "path/to/a/library/that/need/browser/globals",
    "path/to/another/library/that/need/browser/globals",
  ]}
>
  {(theFirstLibrary, theSecondLibrary) => (<Child />)}
</IsomorphicLoader>