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
@react-ram
react-ram / App.js
Created October 23, 2019 08:44
Basics - Lists & keys example 2.
import React, { Component } from "react";
export class App extends Component {
render() {
const todos = [
{ id: 1, text: "do something" },
{ id: 2, text: "do something else" },
{ id: 3, text: "do nothing" }
];
const todoItems = todos.map(todo => <li key={todo.id}>{todo.text}</li>);
@react-ram
react-ram / App.js
Created October 23, 2019 08:29
Basics - Lists and keys example 1.
import React, { Component } from "react";
export class App extends Component {
render() {
const numbers = [1, 2, 3, 4, 5];
return (
<div>
<NumbersList numbers={numbers} />
</div>
@react-ram
react-ram / App.js
Created October 22, 2019 10:26
basics - preventing component from rendering example ( hint: use null)
import React, { Component } from "react";
export class App extends Component {
constructor(props) {
super(props);
this.state = {
warn: true
};
this.handleToggle = this.handleToggle.bind(this);
}
@react-ram
react-ram / App.js
Created October 22, 2019 10:04
basics - conditional rendering with inline conditional or ternery operator ?: example
import React, { Component } from "react";
export class App extends Component {
constructor(props) {
super(props);
this.state = {
isLoggedin: true
};
this.loginHandler = this.loginHandler.bind(this);
this.logoutHandler = this.logoutHandler.bind(this);
@react-ram
react-ram / App.js
Created October 22, 2019 09:37
basics - conditional rendering with inline logical && operator example
import React from "react";
const messages = ["react", "angular", "javascript"];
function App() {
return <MailBox unreadMessages={messages} />;
}
function MailBox(props) {
const unreadMessages = props.unreadMessages;
@react-ram
react-ram / App.js
Created October 22, 2019 09:12
basics - conditonal rendering example
import React, { Component } from "react";
class App extends Component {
constructor(props) {
super(props);
this.state = {
isLoggedin: false
};
this.handleLogin = this.handleLogin.bind(this);
this.handleLogout = this.handleLogout.bind(this);
@react-ram
react-ram / App.js
Created July 24, 2019 09:48
Example: Lifting the state up
import React, { Component } from "react";
import "./App.css";
import Calculator from "./Calculator";
export class App extends Component {
render() {
return (
<div className="App">
<Calculator />
</div>
@react-ram
react-ram / App.js
Created July 22, 2019 18:58
render props example
import React, { Component } from "react";
import Counter from "./Counter";
import ClickCounter from "./ClickCounter";
import HoverCounter from "./HoverCounter";
class App extends Component {
render() {
return (
<div>
<Counter
@react-ram
react-ram / App.js
Last active December 2, 2019 17:33
Higher Order Component example
import React, { Component } from "react";
import ClickCounter from "./ClickCounter";
import HoverCounter from "./HoverCounter";
class App extends Component {
render() {
return (
<div>
<ClickCounter />
@react-ram
react-ram / App.js
Last active July 21, 2019 13:45
EXAMPLE FOR : forwarding Ref's
function App() {
return (
<div className="App">
<Parent />
</div>
);
}