Skip to content

Instantly share code, notes, and snippets.

View Manntrix's full-sized avatar
🏠
Working from home

React Developer Manntrix

🏠
Working from home
View GitHub Profile
import AWS from "aws-sdk";
import { useState } from "react";
function App() {
// Create state to store file
const [file, setFile] = useState(null);
// Function to upload file to s3
const uploadFile = async () => {
// S3 Bucket Name
const uploadFile = async () => {
const S3_BUCKET = "bucket-name";
const REGION = "region";
AWS.config.update({
accessKeyId: "youraccesskeyhere",
secretAccessKey: "yoursecretaccesskeyhere",
});
const s3 = new AWS.S3({
params: { Bucket: S3_BUCKET },
import { useState } from "react";
function App() {
const [file, setFile] = useState(null);
const handleFileChange = (e) => {
const file = e.target.files[0];
setFile(file);
};
return (
<div className="App">
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"PUT",
"POST",
"DELETE",
"GET"
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicListGet",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:List*",
"s3:Get*"
import Cookies from "js-cookie";
function App() {
// Method to set data in cookies which will expire in 7 days
const SetCookie = () => {
Cookies.set("token", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9", {
expires: 7,
});
};
import Stopwatch from "./Stopwatch";
function App() {
return (
<div className="App">
<Stopwatch />
</div>
);
}
body {
background-color: #000;
}
.stopwatch-time {
text-align: center;
color: #fff;
font-size: 80px;
}
import React, { useState, useEffect } from "react";
import "./stopwatch.css";
const Stopwatch = () => {
// state to store time
const [time, setTime] = useState(0);
// state to check stopwatch running or not
const [isRunning, setIsRunning] = useState(false);
useEffect(() => {
import React, { useState, useEffect } from "react";
const App = () => {
const [posts, setPosts] = useState([]);
const getData = () => {
var requestOptions = {
method: "GET",
redirect: "follow",
};