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
| "Ersätt den här texten med domain och clientId från appens inställningar i Auth0" |
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 { Pie, Bar, Line } from 'react-chartjs-2'; | |
| import { data1, data2 } from './demoData' | |
| const DemoChart = () => ( | |
| <div className="demo-chart"> | |
| <Bar data={data1} /> | |
| <Bar data={data2} /> | |
| </div> | |
| ) |
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 packages, route middleware, and initialize app | |
| import express, { Express, Request, Response } from 'express' | |
| const app = express() | |
| const port: number = 1337 | |
| const pathToDist: string = 'dist' | |
| // ---------------------------------------------------- | |
| // Install any middleware before adding routes | |
| // Important middleware: cors, static folders |
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
| public void Print() | |
| { | |
| Queue<Node<T>?> nodes = new Queue<Node<T>?>(); | |
| Queue<Node<T>?> newNodes = new Queue<Node<T>?>(); | |
| nodes.Enqueue(Root); | |
| int depth = 0; | |
| bool exitCondition = false; | |
| while (nodes.Count > 0 && !exitCondition) | |
| { |
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
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| using System.Threading.Tasks; | |
| namespace Datalogi_1 | |
| { | |
| public class Sort | |
| { |
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 produce from 'immer' | |
| import { useState } from 'react' | |
| // Move the interface to a separate file, User.ts | |
| interface User { | |
| id: number; | |
| name: string; | |
| } | |
| // Many times, a variable may not have received its value yet. Use the TypeScript union operator to make that clear. A common use case is when fetching data from an API. |
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
| // src/components/Counter.jsx | |
| import { useDispatch, useSelector } from 'react-redux' | |
| import { actions } from '../features/counter' | |
| const Counter = () => { | |
| // dispatch används för att skicka actions till store, så att reducers kan producera nästa state | |
| const dispatch = useDispatch() | |
| // useSelector väljer ut en del av state från Redux store. "counter" är namnet på din reducer i rootReducer-filen. | |
| const count = useSelector(state => state.counter) |
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 { createContext, useState, useContext } from 'react' | |
| // Create the context in a separate file. Import it to every component that needs it. | |
| const CounterContext = createContext(0) | |
| const ContextDemo = () => { | |
| const [count, setCount] = useState(2) | |
| const contextValue = { count, setCount } |
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
| /* | |
| console.log('Hello world') // apostrof (enkelfnutt) | |
| console.log("Hello world") // citattecken (dubbelfnutt) | |
| console.log(`Hello world`) // grav accent, backtick | |
| */ | |
| const exempel = 15 // global, gäller i hela filen | |
| console.log(exempel) | |
| // definiera funktionen sayName | |
| function sayName(name) { |
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
| const prompt = require('prompt-sync')() | |
| /* | |
| Before running this code, make sure to create an npm project: | |
| npm init -y | |
| npm install prompt-sync | |
| node input.js | |
| */ | |
| // How to get input from user |