Skip to content

Instantly share code, notes, and snippets.

View harshq's full-sized avatar
👋

Harshana Abeyaratne harshq

👋
View GitHub Profile
"use client"
import React, { use } from 'react'
const UseApiClientComponent: React.FC<{ data: any }> = ({ data }) => {
// we pass the promise to use.
const response = use(data)
// and we get data.
return <pre>{JSON.stringify(response, undefined, 2)}</pre>
}
import React, { Suspense } from 'react'
import UseApiClientComponent from './use-api-client-component';
import ErrorBoundary from './ErrorBoundry';
import ExampleSection from '../shared/ExampleSection';
const UseApiServerComponent: React.FC = () => {
// promise is created on the server component
const promise = fetch(`https://jsonplaceholder.typicode.com/posts/1`, { cache: 'no-store' }).then(res => res.json())
return (
<ExampleSection>
"use client"
import React, { use } from 'react'
import ExampleSection from '../shared/ExampleSection';
import { ThemeContext } from './themeContext';
const UseApiClientContext: React.FC = () => {
const theme = use(ThemeContext)
return (
<ExampleSection>

React.js software engineer practical test

In this practical test, we build a simple CRUD application called 🍔 The Fridge. We use this application to see what we have in our fridge at a glance and when do they expire.

Please read the instructions properly before you proceed.

⚙️ Tech Stack to be used

  • React.js (Latest)
  • SASS Stylesheets (scss)
@harshq
harshq / main.go
Created October 17, 2021 08:05
Simple http api lambda handler in Go
package main
import (
"encoding/json"
"fmt"
"github.com/aws/aws-lambda-go/events"
runtime "github.com/aws/aws-lambda-go/lambda"
)
@harshq
harshq / test-api.go
Last active October 17, 2021 06:23
aws-cdk with Golang
package main
import (
"github.com/aws/aws-cdk-go/awscdk"
"github.com/aws/aws-cdk-go/awscdk/awsapigatewayv2"
"github.com/aws/aws-cdk-go/awscdk/awsapigatewayv2integrations"
"github.com/aws/aws-cdk-go/awscdk/awslambdago"
"github.com/aws/constructs-go/constructs/v3"
"github.com/aws/jsii-runtime-go"
)
@harshq
harshq / webpack.config.js
Last active July 25, 2021 07:49
React with Webpack 5
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const PORT = 3001;
module.exports = {
entry: path.resolve(__dirname, "./src/index.js"),
devServer: {
contentBase: path.join(__dirname, "dist"),
port: PORT,
@harshq
harshq / package.json
Created July 25, 2021 07:00
Module federation with Webpack 5
...
"scripts": {
"start": "webpack serve --open --mode development",
"build": "webpack --mode production",
"serve": "serve dist -p 3001",
"clean": "rm -rf dist"
},
...
@harshq
harshq / babel.config.json
Created July 25, 2021 06:54
Module federation with Webpack 5
{
"presets": ["@babel/preset-env", ["@babel/preset-react", {
"runtime": "automatic"
}]]
}
@harshq
harshq / webpack.config.js
Created July 25, 2021 06:43
Module federation with Webpack 5
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin");
const dependencies = require("./package.json").dependencies;
const PORT = 3001;
module.exports = {
entry: path.resolve(__dirname, "./src/index.js"),
devServer: {