BenLorantfy

BenLorantfy

Lorantfy Inc., ApplyBoard, ex-Postmedia IO

Member Since 8 years ago

Lorantfy Inc., Kitchener, Ontario

Experience Points
16
follower
Lessons Completed
8
follow
Lessons Completed
29
stars
Best Reply Awards
49
repos

1622 contributions in the last year

Pinned
⚡ Asynchronous injectors for Redux reducers and sagas. As used by react-boilerplate.
⚡ Use Danger to lint your commit messages
⚡ A command prompt remake of the classic arcade game.
⚡ A remake of pong in c#
⚡ Programming Practice
Activity
Oct
22
1 month ago
Activity icon
issue

BenLorantfy issue comment styled-components/styled-components

BenLorantfy
BenLorantfy

Maintain stable style prop references in React Native

related #3149, #3020

BenLorantfy
BenLorantfy

@rikur I don't think I've ever touched this area of the code - sorry but I don't think I can give you an answer here.

Oct
12
1 month ago
Activity icon
issue

BenLorantfy issue comment nytimes/react-tracking

BenLorantfy
BenLorantfy

Add mergeOptions config option

BenLorantfy
BenLorantfy

yeah sorry been busy recently but I'll try to clean this up and add some docs 👍

Oct
6
2 months ago
Activity icon
issue

BenLorantfy issue comment react-boilerplate/redux-injectors

BenLorantfy
BenLorantfy

React 16.13 throws a warning when "nesting" useInjectReducer calls

After upgrading to React 16.13, we started getting this warning in many places:

image

More info about it in the 16.13 announcement post.

Here's how it happens in our case:

  • Have ParentContainer with useInjectReducer
  • Have ChildContainer with useInjectReducer
  • When ChildContainer's useInjectReducer is called, the warning appears.

This happens because calling useInjectReducer calls store.replaceReducer synchronously during the render of the ChildContainer.

From what I understand, we're not technically updating the state of a component during the render of another component but we are updating the ReactReduxContext - which contains the store and is also consumed by ParentContainer via useStore inside useInjectReducer - so that must be enough to trigger the warning.

The suggestion by the React team is to "wrap the setState call into useEffect".

Up until September of last year, this is exactly how useInjectReducer worked: injection happened inside an effect. However, doing the injection inside an effect caused a different issue: we couldn't guarantee that the reducer or saga was always injected before a relevant action is dispatched. (Discussed in RBP here.)

Does anyone have any thoughts or suggestions regarding how we could fix this?

BenLorantfy
BenLorantfy

@joejordan this pattern is unfortunately not possible anymore without getting the warning here.

The reason this used to work was because the reducer was being injected during the render. Injecting a reducer is usually a side-effect, which is what react is warning about here.

You would have to re-structure the code in this case so useSelector is called within a child of FeatureAppLoader. You could also try the new createManager api which would not have this problem.

Sep
29
2 months ago
Activity icon
issue

BenLorantfy issue comment react-boilerplate/redux-injectors

BenLorantfy
BenLorantfy
BenLorantfy
BenLorantfy

@joejordan @Scott-HangarA I'm doing some more testing before releasing this. You can install version 2.0.0-rc in the meantime.