This file contains hidden or 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
| import React, { useEffect, useState } from "react" | |
| const useMedia = (query: string): boolean => { | |
| const [matches, setMatches] = useState(false) | |
| useEffect(() => { | |
| const queryObject = window.matchMedia(query) | |
| setMatches(queryObject.matches) | |
| const listener = (e: MediaQueryListEvent) => { |
This file contains hidden or 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
| useEffect(() => { | |
| const controller = new AbortController() | |
| fetch("/some-data.json", { signal: controller.signal }) | |
| .then((response) => response.json()) | |
| .then((data) => { | |
| setData(data) | |
| }) | |
| return () => { |
This file contains hidden or 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
| import React, { useEffect, useState } from "react" | |
| export const LoadDataFunction = () => { | |
| const [data, setData] = useState() | |
| useEffect(() => { | |
| fetch("/some-data.json") | |
| .then((response) => response.json()) | |
| .then((data) => { | |
| setData(data) |
This file contains hidden or 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
| import React from "react" | |
| export class LoadDataClass extends React.Component { | |
| componentDidMount(): void { | |
| fetch("/some-data.json") | |
| .then((response) => response.json()) | |
| .then((data) => { | |
| this.setState({ data }) | |
| }) | |
| } |
This file contains hidden or 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
| import React, { FC, useState } from "react" | |
| import "./expansion-box.css" | |
| type Props = { | |
| title: string | |
| } | |
| export const ExpansionBoxFunction: FC<Props> = (props) => { | |
| const [expanded, setExpanded] = useState(false) |
This file contains hidden or 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
| import React from "react" | |
| import "./expansion-box.css" | |
| type Props = { | |
| title: string | |
| } | |
| type State = { | |
| expanded: boolean | |
| } |
This file contains hidden or 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
| package org.example; | |
| import javafx.application.Application; | |
| import javafx.fxml.FXMLLoader; | |
| import javafx.scene.Parent; | |
| import javafx.scene.Scene; | |
| import javafx.stage.Stage; | |
| public class App extends Application { |
This file contains hidden or 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
| import javafx.application.Application; | |
| import javafx.event.EventHandler; | |
| import javafx.event.EventType; | |
| import javafx.scene.Scene; | |
| import javafx.scene.control.ComboBox; | |
| import javafx.scene.control.TextField; | |
| import javafx.scene.input.KeyEvent; | |
| import javafx.scene.layout.VBox; | |
| import javafx.stage.Stage; |
This file contains hidden or 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
| import javafx.application.Application; | |
| import javafx.scene.Parent; | |
| import javafx.scene.Scene; | |
| import javafx.stage.Stage; | |
| import de.saxsys.mvvmfx.FluentViewLoader; | |
| public class MvvmfxExampleApp extends Application { | |
| public static void main(String... args) { |
This file contains hidden or 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
| /** | |
| * ``` | |
| * Does JDK8's CompletableFuture class satisfy the Monad laws? | |
| * ================================================= | |
| * 1. Left identity: true | |
| * 2. Right identity: true | |
| * 3. Associativity: true | |
| * | |
| * Yes, it does. | |
| * ``` |
NewerOlder