-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e42d0bf
commit 9ae1966
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9ae1966
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.
UseAPI (React Hooks!)
After the pleasure of updating the typescript type definitions (irony), this commit contains the first custom react hook, aimed to simplify doing ajax calls in functional react components.
In order to see how awesome it is, look at this example code:
signumsoftware/southwind@4783afa?diff=split
(The code in Southwind is not merged to master till jquense/react-widgets#917 is accepted)
Why it is awesome
componentWillMount
,componentWillReceiveProps
andloadData
, theuseAPI
takes care of everything.componentWilUnmount
! No more warnings when changing the state of a dead component.this.props.ctx
, justctx
.handleViewClick
is now an inner function, you don't need a lambda andthis
makes no problems.