Skip to content

Conversation

@izaakschroeder
Copy link
Contributor

@izaakschroeder izaakschroeder commented May 17, 2018

Change relocation to use the context API available in react^16.3. This makes portals much more "declarative". Instead of dispatching an action you mount/render a component.

First create an instance:

const Relocation = createRelocation();

Then wrap your app in a provider:

<Relocation.Provider>
  ...
</Relocation.Provider>

Then have a place to consume generated components somewhere:

<Relocation.Consumer>
  {(items) => items.map(({child}) => child)}
</Relocation.Consumer>

Then dispatch components into the aforementioned containers:

<Relocation.Component>
  <div>I am the value of {child} above!</div>
</Relocation.Component>

/cc @10xjs

@@ -1,2 +1,2 @@
env:
mocha: true
jest: true
Copy link
Contributor

@10xjs 10xjs May 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the overrrides feature of the root .eslintrc for this
https://github.com/10xjs/form/blob/master/.eslintrc#L7

export {default as reducer} from './reducer';
export {default} from './connect';
// @flow
export {default} from './createRelocation';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this redundant file to cut down on bundle-size. or use rollup

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think at this point it's so tiny as to be a non-issue. But a good point nonetheless.

// eslint-disable-next-line
UNSAFE_componentWillMount() {
this.props.addChild(this.id, this.props.children, this.props.meta);
}
Copy link
Contributor

@10xjs 10xjs May 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use componentDidMount, and componentDidUpdate to handle side-effects (see: reactjs/rfcs#26)

Hopefully we can use these instead of the lifecycle funcs that are on the chopping block.

@codecov
Copy link

codecov bot commented May 17, 2018

Codecov Report

Merging #34 into master will increase coverage by 11.97%.
The diff coverage is 95.65%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master      #34       +/-   ##
===========================================
+ Coverage   83.67%   95.65%   +11.97%     
===========================================
  Files           5        1        -4     
  Lines          49       46        -3     
  Branches        8        2        -6     
===========================================
+ Hits           41       44        +3     
+ Misses          8        2        -6
Impacted Files Coverage Δ
src/createRelocation.js 95.65% <95.65%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update faf42fa...044c500. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants