Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
lkmill wants to merge1 commit intodevelopit:master
base:master
Choose a base branch
Loading
fromlkmill:react-hooks

Conversation

@lkmill
Copy link

@lkmilllkmill commentedApr 5, 2020
edited
Loading

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:

Build "unistore" to .:        620 B: react.js.gz        531 B: react.js.brBuild "unistore" to full:        801 B: react.js.gz        708 B: react.js.br        809 B: react.es.js.gz        717 B: react.es.js.br        861 B: react.umd.js.gz        757 B: react.umd.js.br
Build "unistore" to .:        466 B: react.js.gz        393 B: react.js.brBuild "unistore" to full:        682 B: react.js.gz        592 B: react.js.br        694 B: react.es.js.gz        616 B: react.es.js.br        741 B: react.umd.js.gz        649 B: react.umd.js.br

With some code golf, eg not using array destructuring, it is quite simple to reduce the size further but the code becomes less readable.

btzr-io, dan-lee, and Akiyamka reacted with thumbs up emoji
Copy link
Contributor

@AkiyamkaAkiyamka left a 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 }) { }}
*/

Choose a reason for hiding this comment

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

Suggested change

returnChild=>functionWrapper(props){
conststore=useContext(Context);
let[state=mapStateToProps(store ?store.getState() :{},props),setState]=useState();
boundActions=boundActions||actions ?mapActions(actions,store) :{ store};

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();

Choose a reason for hiding this comment

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

Suggested change
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);
},[]);

Choose a reason for hiding this comment

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

Suggested change
},[]);
},[store]);

Might want to at least put thestore in here
maybe props as well?

@ForsakenHarmony
Copy link

Super old PR lol 🙃

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

Reviewers

2 more reviewers

@AkiyamkaAkiyamkaAkiyamka left review comments

@ForsakenHarmonyForsakenHarmonyForsakenHarmony left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Remove depracated in react 16.9 componentWillReceiveProps

3 participants

@lkmill@ForsakenHarmony@Akiyamka

[8]ページ先頭

©2009-2025 Movatter.jp