Skip to content

Instantly share code, notes, and snippets.

@hiquest hiquest/nothis.jsx
Created Oct 5, 2018

Embed
What would you like to do?
No this in React
import React from 'react'
// ... other imports
import nothis from '../shared/nothis'
export default nothis({
willMount,
render,
})
function render({ state: { loading, card }, setState }) {
return (
<div className="card">
{ loading && <Spinner /> }
{ !loading && (
<div>
<span>{ card.name }</span>
<a onClick={remove}>Remove</a>
</div>
) }
<span>{ card.name }</span>
</div>
)
async function remove() {
setState({ loading: true })
await remove(card.id)
setState({ loading: false, card: undefined})
}
}
async function willMount({ setState }) {
setState({ loading: true })
const card = await fetchCard()
setState({ card, loading: false })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.