Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

Commit

Permalink
Use effects for setroot instead of cached state
Browse files Browse the repository at this point in the history
  • Loading branch information
flopes89 committed Feb 14, 2020
1 parent 6ddb99a commit e8e1cf7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/client/components/files/filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const Filter: React.FC = () => {

return (
<Row>
<Col xs={3}>
<Col xs={1}>
<strong>Filters</strong>
</Col>
<Col>
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/files/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const FileList: React.FC = () => {
<Col>
<Filter />
</Col>
<Col xs={4} className="text-right">
<Col xs={2} className="text-right">
<Label check className="pl-2">
<Input
type="checkbox"
Expand Down
8 changes: 6 additions & 2 deletions src/client/components/global/setRoot.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useState, useEffect } from "react";
import { Button, ButtonGroup, Col, Modal, ModalBody, ModalHeader, Row } from "reactstrap";
import Octicon, { Inbox } from "@primer/octicons-react";
import { Loading } from "../util";
Expand Down Expand Up @@ -109,7 +109,11 @@ const FolderSelection: React.FC<FolderSelectionProps> = (props) => {

export const SetRoot: React.FC = () => {
const { data } = useConfigQuery();
const [isOpen, setIsOpen] = useState(Boolean(data?.config.root));
const [isOpen, setIsOpen] = useState(false);

useEffect(() => {
setIsOpen(!Boolean(data?.config.root));
}, [data]);

if (!data) {
return <Loading />;
Expand Down

0 comments on commit e8e1cf7

Please sign in to comment.