Skip to content

Commit

Permalink
admin: RouteEditor component should handle new undefined paths.
Browse files Browse the repository at this point in the history
  • Loading branch information
octavore committed Jun 3, 2018
1 parent 9a1e272 commit 351e320
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions admin/src/js/pages/page/edit_route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,27 @@ interface EditorState {
}

class RouteEditor extends React.Component<EditorProps, EditorState> {
readonly originalPath: string;
readonly storeKey: string;
constructor(props: EditorProps) {
super(props);
this.state = {
path: this.getRoute().path || '',
};
this.originalPath = this.state.path;
this.storeKey = this.state.path || 'new-path';
}

getRoute = () => this.props.routesStore.obj.current[this.props.index];

componentDidMount() {
this.props.routesStore.subscribe(this.originalPath, (data) => {
this.props.routesStore.subscribe(this.storeKey, (data) => {
this.setState({
path: data.current[this.props.index].path || '',
});
});
}

componentWillUnmount() {
this.props.routesStore.unsubscribe(this.originalPath);
this.props.routesStore.unsubscribe(this.storeKey);
}

render() {
Expand Down

0 comments on commit 351e320

Please sign in to comment.