Skip to content

Instantly share code, notes, and snippets.

View react-ram's full-sized avatar
🏠
Working from home

Ramcharan Madasu react-ram

🏠
Working from home
  • Hyderabad, India
View GitHub Profile
const _mergeArrays = (a, b) => {
const c = []
while (a.length && b.length) {
if( a[0][0] == b[0][0] ) {
if( a[0][1] < b[0][1] ) {
c.push(a.shift());
} else {
c.push(b.shift());
}
@react-ram
react-ram / App.js
Created May 1, 2020 08:59
Basic React Router DOM Example - 1
import React from "react";
import "./App.css";
import { BrowserRouter as Router, Route, Switch, Link } from "react-router-dom";
function LandingView() {
return <div>LandingView</div>;
}
function Login() {
return (
@react-ram
react-ram / App.js
Last active January 27, 2020 17:28
Context API example 1
import React from "react";
import CompoC from "./CompC";
import { UserProvider } from "./userContext";
export default function App() {
return (
<div>
<UserProvider value="ram">
<CompoC />
<CompD />
@react-ram
react-ram / sample.js
Created January 9, 2020 07:41
dashboard sample code
import React, {Component} from 'react';
import {View, ScrollView} from 'react-native';
import {List, Divider, Colors} from 'react-native-paper';
const vehicles = [
{id: 1, no: 'AP28X1234'},
{id: 2, no: 'AP28X1222'},
{id: 3, no: 'AP28X1333'},
{id: 4, no: 'AP28X1234'},
{id: 5, no: 'AP28X1222'},
@react-ram
react-ram / index.js
Created November 25, 2019 03:13
Basics - Introducing JSX - example 2.
import React from "react";
import ReactDOM from "react-dom";
function formatName(user) {
return user.first + " " + user.last;
}
const user = {
first: "ram",
last: "charan"
@react-ram
react-ram / index.js
Created November 24, 2019 17:17
Basics - Introducing JSX - Example 1
import React from "react";
import ReactDOM from "react-dom";
//JSX
const name = "ramcharan";
const element = <h1>hello {name}</h1>;
ReactDOM.render(element, document.getElementById("root"));
@react-ram
react-ram / index.js
Last active November 24, 2019 17:47
Basics - Hello world example
import React from "react";
import ReactDOM from "react-dom";
ReactDOM.render(<h1>hello world</h1>, document.getElementById("root"));
@react-ram
react-ram / App.js
Created October 23, 2019 09:28
Basics - Lists & keys example 5. Using map( ) in JSX.
import React, { Component } from "react";
class App extends Component {
render() {
const numbers = [1, 2, 3, 4, 5];
return (
<ul>
{numbers.map(number => (
<li key={number.toString()}>{number}</li>
))}
@react-ram
react-ram / App.js
Created October 23, 2019 09:22
Basics - Lists & keys example 4. usage of same key for different arrays.
import React, { Component } from "react";
export class App extends Component {
render() {
const posts = [
{ id: 1, title: "hello world", content: "welcome to the react world" },
{
id: 2,
title: "installation",
content: "you can install react from npm"
@react-ram
react-ram / App.js
Created October 23, 2019 09:00
Basics - Lists & keys - correct usage of key. example 3
import React, { Component } from "react";
export class App extends Component {
render() {
const numbers = [1, 2, 3, 4, 5];
return (
<div>
<NumbersList numbers={numbers} />
</div>
);