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
class EventComponent extends React.Component<{}, { count: number }> { | |
state = { | |
count: 0, | |
}; | |
handleClick = (event: SyntheticEvent<HTMLButtonElement>) => { | |
// To access your button instance use `event.currentTarget`. | |
(event.currentTarget: HTMLButtonElement); | |
this.setState(prevState => ({ |
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
type TextProps = { | |
name: string | |
} | |
type State = { | |
count: number, | |
}; | |
class Text extends React.Component<TextProps, State> { |
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
type TextProps = { | |
name: string | |
} | |
class Text extends React.Component<TextProps> { | |
render () { | |
return ( | |
<React.Fragment> | |
<p>{this.props.name}</p> |
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
type TextProps = { | |
name: string | |
} | |
class Text extends React.Component<TextProps> { | |
render () { | |
return ( | |
<React.Fragment> | |
<p>{this.props.name}</p> |
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
type TextProps = { | |
} | |
class App extends React.Component<TextProps> { | |
render() { | |
return ( | |
<div className="App"> | |
<header className="App-header"> | |
<img src={logo} className="App-logo" alt="logo" /> |
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
const Placeholder = ({ delayMs, fallback, children }) => { | |
return ( | |
<Timeout ms={delayMs}> | |
{didExpire => { | |
return didExpire ? fallback : children; | |
}} | |
</Timeout> | |
); | |
} |
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
export default class App extends React.Component { | |
render() { | |
return ( | |
<React.Fragment> | |
<div className="App"> | |
<header className="App-header"> | |
<h1 className="App-title">React Suspense Demo</h1> | |
</header> |
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
const Movies = withCache( (props) => { | |
const result = readShows(props.cache); | |
return ( | |
<React.Fragment> | |
{result && | |
result.length && | |
result.map(item => ( | |
<div className="column is-4"> |
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
const Movies = withCache( (props) => { | |
return ( | |
<React.Fragment> | |
<div className="column is-4"> | |
<div className="movie"> | |
<div className="movie__left"> | |
<img src /> | |
</div> | |
<div className="movie__right"> |
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
const sleep = ms => new Promise(r => setTimeout(() => r(), ms)); | |
const readShows = createResource(async function fetchNews() { | |
await sleep(3000); | |
const res = await fetch(`http://api.tvmaze.com/search/shows?q=suits`); | |
return await res.json(); | |
}); |