NoThis.Component for React
A this-free way of creating a React component.
Create React component without the need for this
. The context is passed in as the first argument to all methods (unless excluded).
Save your future self some time and never debug this
again!
NULL is considered to the a Billion dollar mistake. How much will this
cost us?
Installation
Same way you install everything with JavaScript...
npm install -P nothis-react
NoThis.Component
NoThis.Component
works in a familiar way to React.Component
because it inherits from React.Component
.
The context you would previously access via this
is available as the first function argument.
Component state = count: 0 { ctx } { return <div> <button onClick=ctxincrement>ctxstatecount</button> </div> }
Argument Destructuring
If you love destructuring as much as I do, then code like this now becomes possible!
Component state = count: 0 { } { return <div> <button onClick=increment>count</button> </div> }
Excluding Functions
A function can be excluded from nothis
by writing it as a class property.
Component { this }