- Notifications
You must be signed in to change notification settings - Fork137
WIP fix #171 Convert react integration to use hooks#186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Akiyamka left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
lgfm
| *@connect( state => ({ foo: state.foo, bar: state.bar }) ) | ||
| * export class Foo { render({ foo, bar }) { }} | ||
| */ | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
| returnChild=>functionWrapper(props){ | ||
| conststore=useContext(Context); | ||
| let[state=mapStateToProps(store ?store.getState() :{},props),setState]=useState(); | ||
| boundActions=boundActions||actions ?mapActions(actions,store) :{ store}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I thinkuseMemo would be a lot better here, this seems way too likely to break
| letboundActions; | ||
| returnChild=>functionWrapper(props){ | ||
| conststore=useContext(Context); | ||
| let[state=mapStateToProps(store ?store.getState() :{},props),setState]=useState(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
| let[state=mapStateToProps(store ?store.getState() :{},props),setState]=useState(); | |
| let[state,setState]=useState(mapStateToProps(store ?store.getState() :{},props)); |
| return(Wrapper.prototype=Object.create(Component.prototype)).constructor=Wrapper; | ||
| returnstore.subscribe(update); | ||
| },[]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
| },[]); | |
| },[store]); |
Might want to at least put thestore in here
maybe props as well?
ForsakenHarmony commentedApr 28, 2022
Super old PR lol 🙃 |
Uh oh!
There was an error while loading.Please reload this page.
Tofix#171 and not use any UNSAFE_ methods, i converted the react integration to use hooks.
I haven't updated the tests yet, want to hear whether this is an acceptable change first.
Besides removing the warnings, this also greatly reduces the build file sizes:
Before:
With some code golf, eg not using array destructuring, it is quite simple to reduce the size further but the code becomes less readable.