Skip to content

Zenika/react-isomorphic-loader

Repository files navigation

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

Parameter Type Required Default value Description
libraries string|string[] yes undefined It represents a path or a list of paths to frontend libraries.
strict bool no true If 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>

About

An higher order component to load frontend libraries only in browser for react isomorphic apps

Resources

License

Stars

Watchers

Forks

Packages

No packages published