frintjs / frintjs/frint

Proposal: Access to `app` instance synchronously

Open
#424 4 comments 0 reactions 0 assignees View on GitHub
help wanted proposal
Dominant language
JavaScript
Stars
756
Forks
33
PR merge metrics
No merged PRs in 30d

Description

## Currently

Components can only access the `app` instance via `observe` HoC, which also involves RxJS for streaming props:

```js
import React from 'react';
import { observe } from 'frint-react';

function MyComponent() {
return

;
}

export default observe(function (app, parentProps$) {
return props$;
})(MyComponent);
```

## Proposal

Not everyone needs to work with streaming props, and may only want to be able to access the `app` instance (which has the providers), and carry on with regular React lifecycle operations.

To achieve that, we can extend `frint-react`:

### 1: `withApp` function

```js
import React from 'react';
import { withApp } from 'frint-react';

function MyComponent() {
return

;
}

export withApp((app, props) => );
```

### 2: `WithApp` component with render prop

This may not be necessary. Just `withApp` function alone should be enough.

```js
import React from 'react';
import { WithApp } from 'frint-react';

export default function MyComponent() {
return (

{
(app, props) =>


}

);
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.