You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// In the browser, calling 'User.get()' will actually make a HTTP request
// to the server, which will make the actual function call,
// serialize the results back to the browser, and resolve the promise with the value(s).
//
// In the server, 'User.get()' will be called directly
// without doing any HTTP requests or any routing whatsoever.
//
// This same piece of code can be run seamlessly in the browser and the server
export default class MyComponent extends React.Component {
async componentDidMount() {
const user = await User.get(123);
this.setState({ user });
}
}
"In the server, 'User.get()' will be called directly"
componentDidMount is called on client render only. So perhaps it makes more sense to put this call in componentWillMount to demonstrate it working on the server.
The text was updated successfully, but these errors were encountered:
setState in componentWillMount is an anti-pattern, and doesn't defer rendering for server render unless some special treatment is applied, so might not be a beneficial suggestion.
I suppose the example here shows proper server side usage:
@d-oliveros, for the documentation below
"In the server, 'User.get()' will be called directly"
componentDidMount
is called on client render only. So perhaps it makes more sense to put this call incomponentWillMount
to demonstrate it working on the server.The text was updated successfully, but these errors were encountered: