0.1.17 • Published 1 year ago

@grexie/compose v0.1.17

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Grexie Compose

Create and use composable functions for React context providers and other wrapper components.

Installing

yarn add @grexie/compose

Usage

Create a composable from an existing component, for example a context provider:

import { createComposable } from "@grexie/compose";

const withContextProvider = createComposable(ContextProvider);

Then use the composable with the compose function:

import { compose } from "@grexie/compose";

const ComposedApp = compose(
  withContextProvider1,
  withContextProvider2,
  ...,
  withContextProviderN,
  App
);

You can chain as many composables together in the call to compose, avoiding the need to chain multiple JSX tags together to compose the App wrapper.

Or alternatively, if your composable function takes props in addition to children:

import { createComposableWithProps, compose } from "@grexie/compose";

const withContextProvider1 =
  createComposableWithProps<PropsType>(ContextProvider);

const ComposedApp = compose(
  withContextProvider1({ ...props }),
  withContextProvider2,
  ...,
  withContextProviderN,
  App
);
0.1.11

1 year ago

0.1.12

1 year ago

0.1.13

1 year ago

0.1.14

1 year ago

0.1.15

1 year ago

0.1.16

1 year ago

0.1.17

1 year ago

0.1.10

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago