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 { mutate, invalidate } = useRestable() | |
const orderRecord = await mutate( | |
OrderRecord.create({ /* payload */ }) | |
) | |
await invalidate( | |
// Invalidate the list of all OrderRecords | |
{ model: OrderRecord, many: true }, | |
// Invalidate the list of OrderRecords for this instrumentId | |
{ model: OrderRecord, many: true, params: { instrumentId } }, | |
) |
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 dispatch = useDispatch() | |
await dispatch(OrderRecord.issueCreate( | |
{ /* no static typing */ } | |
)).meta.promise | |
// Refresh all OrderRecords, | |
// to ensure the account history page is up-to-date | |
const refresh1 = dispatch(OrderRecord.issueQuery({}, { | |
fetchLimit: 0 | |
})).meta.promise | |
// Also refresh OrderRecords filtered by this instrumentId, |
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
// router concepts | |
// - route declaration (abstract) vs. route implementation (concrete) | |
// - transitionIds | |
// - onPrepare, onTransitionStart, onTransitionEnd | |
// - global click handler | |
// - useRouterState, useRouterActions | |
type RouteInfo = { | |
name: string; | |
params: { [key]: string }; |
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
<CommentTemplate metadata={metadata} actions={actions}> | |
{text} | |
</CommentTemplate> |
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 Document extends React.Component { | |
render() { | |
// ... | |
} | |
} | |
export default withLinkAnalytics((props) => ({ | |
documentId: props.documentId | |
}), Document); |
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
function withLinkAnalytics(mapPropsToData, WrappedComponent) { | |
class LinkAnalyticsWrapper extends React.Component { | |
componentDidMount() { | |
ReactDOM.findDOMNode(this).addEventListener('click', this.onClick); | |
} | |
componentWillUnmount() { | |
ReactDOM.findDOMNode(this).removeEventListener('click', this.onClick); | |
} |
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 Document extends React.Component { | |
componentDidMount() { | |
ReactDOM.findDOMNode(this).addEventListener('click', this.onClick); | |
} | |
componentWillUnmount() { | |
ReactDOM.findDOMNode(this).removeEventListener('click', this.onClick); | |
} | |
onClick = (e) => { |
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 Comment extends React.Component { | |
render() { | |
const metadata = this.props.publishTime ? | |
<PublishTime time={this.props.publishTime} /> : | |
<span>Saving...</span>; | |
const actions = []; | |
if (this.props.isSignedIn) { | |
actions.push(<LikeAction />); | |
actions.push(<ReplyAction />); |
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 CommentTemplate extends React.Component { | |
static propTypes = { | |
// Declare slots as type node | |
metadata: PropTypes.node, | |
actions: PropTypes.node, | |
}; | |
render() { | |
return ( | |
<div> |
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 PanelHeader = (props) => ( | |
// ... | |
); | |
const PanelBody = (props) => ( | |
// ... | |
); | |
class Panel extends React.Component { | |
render() { |
NewerOlder