Sha256: 024780fe3291c2775cee131eab89110104c74ca2d31adb6566414ed726f1bba6
Contents?: true
Size: 869 Bytes
Versions: 2
Compression:
Stored size: 869 Bytes
Contents
// @flow import React from "react"; import type {Location, RouterHistory} from "react-router-dom"; import httpClient from "../http-client"; export default class Base extends React.Component { props: { location: Location; history: RouterHistory; }; state: any; constructor(props: any) { super(props); this.state = {}; } componentDidMount() { this.loadPage(); } componentDidUpdate(prevProps: { location: Location; }) { if (this.props.location.pathname !== prevProps.location.pathname || this.props.location.search !== prevProps.location.search) { this.loadPage(); } } loadPage() { const jsonPathname = this.props.location.pathname.replace(/\.[^/.]+$/, "") + ".json"; httpClient.get(jsonPathname + this.props.location.search) .then(({ data }) => this.setState({ page: data.page })); } }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
admin_core-0.0.2 | client/src/resource-page/Base.js |
admin_core-0.0.1 | client/src/resource-page/Base.js |