tkh44 / react-localforage

👨‍🌾 Declarative localForage in React
MIT License
54 stars 13 forks source link

React 16.3 #3

Open JasonSooter opened 6 years ago

JasonSooter commented 6 years ago

Any knowledge of if this package works with 16.3?

I could make a PR and give it a shot if that is unknown and you are willing.

Looks like exactly what I need but I want to know its still active ;-)

Thanks!

andrewsantarin commented 5 years ago

@functionalStoic April 2019 here. I tried this library on CodeSandbox. Seems to be working so far.

But what I do know from the latest React docs that the componentWillMount and componentWillReceiveProps lifecycle methods (segments down below) will be phased out (official blog post), and unfortunately, this library still makes use of them:

https://github.com/tkh44/react-localforage/blob/01c4aec0c7053eb24ad68c42c5d1d8a5c0aac908/src/index.js#L18-L28

https://github.com/tkh44/react-localforage/blob/01c4aec0c7053eb24ad68c42c5d1d8a5c0aac908/src/index.js#L80-L90

https://github.com/tkh44/react-localforage/blob/01c4aec0c7053eb24ad68c42c5d1d8a5c0aac908/src/index.js#L92-L100

I'd wager this is what needs to be done next:

  1. move the componentDidMount statements to the constructor; since all those methods are doing is just setting initial state, those methods might as well be called in the constructor method.
  2. convert the componentWillReceiveProps statement to componentDidUpdate; okay, this, I admit I don't grasp fairly well, so I'm dealing with this at face value.
JasonSooter commented 5 years ago

@andrewsantarin Thanks for the thoughtful review and recommendation. Unfortunately, I do not have react-localforage in production and no bandwidth to chime in on your recommendations. Hopefully, this will be helpful to others.

andrewsantarin commented 5 years ago

Figured I'd try this out on my own because I find the pattern in this library quite useful for my needs, although the library itself isn't: https://codesandbox.io/s/young-brook-3hn0g, with TypeScript, on top of that. What I've got is almost exactly what I'm using right now for work.

Not a pull request yet by any stretch of the imagination, since it's only the <GetItem> segment.

I'll have to conjure my own repo, perhaps?