Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// State for loading the grade
const { grade, gradeLoading } = useFetchGrade(student);
// The following is state for saving the grade
//
// If there is an error when submitting a grade?
const [submitGradeError, setSubmitGradeError] = useState('');
// Is set to true when the grade is being currently posted to the service
const [gradeSaving, setGradeSaving] = useState(false);
// Changes the input field's background to green for a short duration when true
const [gradeSaved, setGradeSaved] = useState(false);
// The following is state for local validation errors
//
// Is there a validation error message to show?
const [showValidationError, setValidationError] = useState(false);
// The actual validation error message.
const [validationMessage, setValidationMessageMessage] = useState('');
// Unique id attribute for <input>
const gradeId = useUniqueId('SubmitGradeForm__grade:');
const {
api: { authToken },
} = useContext(Config);
// Used to handle keyboard input changes for the grade input field.
const inputRef = useRef(/** @type {HTMLInputElement|null} */ (null));
// Clear the previous grade saved status when the user changes.
useEffect(() => {
setGradeSaved(false);
}, [student]);
export function HighlightPane(props: { treeDom: HTMLDivElement | null }) {
const store = useStore();
const nodes = useObserver(() => store.nodes.$);
const { selected } = useSelection();
const { collapsed } = useCollapser();
// Subscribe to nodeList so that we rerender whenever nodes
// are collapsed
const list = useObserver(() => store.nodeList.$);
let [pos, setPos] = useState({ top: 0, height: 0 });
useEffect(() => {
if (selected > -1 && !collapsed.has(selected)) {
if (props.treeDom != null) {
let start = props.treeDom.querySelector(
`[data-id="${selected}"`,
) as HTMLDivElement | null;
let lastId = getLastChild(nodes, selected);
let last = props.treeDom.querySelector(
`[data-id="${lastId}"]`,
) as HTMLDivElement | null;
if (start != null && last != null) {
const rect = start.getBoundingClientRect();
const top = start.offsetTop + rect.height;
const lastRect = last.getBoundingClientRect();
let height = last.offsetTop + lastRect.height - top;
export default function ReleaseLink(props) {
const [url, setUrl] = useState(URL);
const [version, setVersion] = useState(VERSION);
useEffect(() => {
fetchRelease(config.repo)
.catch(() => ({
version: VERSION,
url: URL
}))
.then(d => {
setVersion(d.version);
setUrl(d.url);
});
}, []);
return (
<a href="{url}">
v{version}
</a>
export function useOverlayToggle() {
const [open, setOpen] = useState(false);
function onResize() {
if (open) setHeight();
}
useEffect(onResize, [open]);
useEffect(() => {
window.addEventListener('resize', onResize);
return () => window.removeEventListener('resize', onResize);
}, [open]);
return [open, setOpen];
}
popupContent,
onChange,
className = "",
...restProps
}: {
buttonContent: React.Node,
popupContent: ({ close: () => void }) => React.Node,
open?: boolean,
onChange?: boolean => void,
className?: string,
...
}) {
const onChangeRef = useRef();
onChangeRef.current = onChange;
const [openState, setOpenState] = useState(false);
const open = openProp != null ? openProp : openState;
const rootRef = useRef();
const setOpen = useCallback(
newOpen => {
if (openProp == null) {
setOpenState(newOpen);
}
if (onChangeRef.current != null) {
onChangeRef.current(newOpen);
}
},
[openProp]
);
export const ComponentSelected = function () {
const [isSelected, setIsSelected] = useState(true)
function handleClick () {
setIsSelected(!(isSelected === true))
}
return (
Text
)
}
const ArkFarming = ({
config,
data,
planner_service,
level_id: level_query,
}) => {
const {
state: { stock, records, compound_materials },
load,
adjustStockItem,
} = data;
const summary = useMemo(() => sumRequirements(records, stock, compound_materials), [records, stock, compound_materials]);
const [level_id, setLevelId_raw] = useState(global.level_query);
const [grouping_type, setGroupingType_raw] = useState(global.grouping_type || 'default');
const [filter_type, setFilterType_raw] = useState(global.filter_type || 'shortage');
const filters = {
shortage: item => summary[item.id] && Math.max(summary[item.id] - (stock[item.id] || 0), 0) > 0,
required: item => summary[item.id],
exceeded: item => Math.max((stock[item.id] || 0) - summary[item.id], 0) > 0,
};
const itemFilter = filters[filter_type] || null;
const setLevelId = (id) => {
if (id && typeof id === 'string') {
try {
global.ga('send', {
hitType: 'event',
eventCategory: 'farming_level_filter',
const Sports = ({ req, params }) => {
const [clicks, setClicks] = useState(0);
return (
<div>
<h1>Sports</h1>
<code>
ID: {params.id}<br>
Segment: {params.segment}
</code>
<p>{clicks}</p>
<p>
<button> setClicks(clicks + 1)}>Add</button>
</p>
asd
</div>
const App = (props) => {
const [currentUrl, setCurrentUrl] = useState('/');
const {
config,
load,
toggleShowAllResources,
toggleShowFocusMaterials,
toggleShowFilter,
toggleShowExp,
toggleShowAnnouncementCodeOnce,
setFilters,
} = useConfig();
const [drops, setDrops] = useState([]);
const data = useData();
useEffect(() => {
export default function Conference({conferences, slug}) {
const conference = conferences.find(conference => conference.slug === slug);
const [comments, setComments] = useState(null);
useEffect(() => {
findComments(conference).then(comments => setComments(comments));
}, [slug]);
return (
<div>
<h4>{conference.city} {conference.year}</h4>
</div>
);
}