Releases: siddharthkp/bae
Releases · siddharthkp/bae
Rebrand to bae!
reaqt has been renamed to bae for easier verbal conversations about it 😅
Reduced time to first byte by streaming
- Uses rapscallion under the hood
- Render some content on the screen fast - don't keep your users waiting
Benchmarks:
ttfb (ms) | total (ms) | |
---|---|---|
without streaming | 151 | 151 |
with streaming | 22 | 110 |
fetch data asynchronously on the server
asyncComponentWillMount
React has a lifecycle method that get's called on the server componentWillMount
that can be used to set data for server rendering. But, it does not support asynchronous data fetching before rendering the component.
reaqt introduces a new lifecycle method to pages that runs only on the server.
import React from 'react'
export default class extends React.Component {
constructor (props) {
super(props)
this.state = {username: 'siddharthkp'}
}
asyncComponentWillMount () {
/*
Return a promise.
It will get resolved on the server and passed as props to the component.
*/
return axios.get(`https://api.github.com/users/${this.state.username}`)
}
render () {
return <div>{this.props.bio}</div>
}
}