Skip to content

Instantly share code, notes, and snippets.

View akulsr0's full-sized avatar

Akul Srivastava akulsr0

View GitHub Profile
@akulsr0
akulsr0 / module.js
Created October 30, 2024 13:13
For demo of nextjs 15 url imports
export const DEMO_CONSTANT = 'I am demo'
export const sum = (a, b) => a + b;
@akulsr0
akulsr0 / data.json
Last active October 25, 2024 15:50
Demo CMS
{
"name": "Akul Srivastava",
"header": {
"title": "welcome to my page"
},
"footer": {
"title": "Thanks for visiting",
"description": "Come back soon!"
}
}
@akulsr0
akulsr0 / greet-component.js
Created June 29, 2022 12:25
Test component via cdn
export function Greet({ name }) {
return <h3>Hello, {name}</h3>;
}

Modules, importing and exporting

CommonJS

Exporting a variable

// user.js
exports.name = "John";
declare function sum(x: number, y: number): string;

Using Redux in ReactJS

  1. Install redux and react-redux

  2. Create state (src/redux/state.js)

// src/redux/state.js

export const numState = {
@akulsr0
akulsr0 / quotes.json
Created February 23, 2022 14:30
Quotes
[
{
"text": "Genius is one percent inspiration and ninety-nine percent perspiration.",
"author": "Thomas Edison"
},
{
"text": "You can observe a lot just by watching.",
"author": "Yogi Berra"
},
{
@akulsr0
akulsr0 / RNAnims - Winner Animation.js
Created September 1, 2021 14:59
RNAnims - Winner Animation
import * as React from "react";
import {
View,
Animated,
Image,
TouchableOpacity,
Text,
Dimensions,
StyleSheet,
} from "react-native";
@akulsr0
akulsr0 / RNUIAPP - Emoji.jsx
Created October 31, 2020 07:32
React Native UI - Emoji
import React, { useState } from 'react';
import {
View,
TextInput,
} from 'react-native';
import Emoji from 'react-native-emoji';
export default function App() {
@akulsr0
akulsr0 / RNUIAPP - PaymentScreen2.jsx
Created October 30, 2020 05:29
React Native UI - Payment Screen 2
import React, { useState } from 'react';
import {
StyleSheet,
Text,
View,
StatusBar,
Image,
TouchableOpacity,
ActivityIndicator,
ScrollView,