Skip to content

Instantly share code, notes, and snippets.

View Kamilnaja's full-sized avatar
💭
🐍🔥

Kamil Naja Kamilnaja

💭
🐍🔥
View GitHub Profile
import React from "react";
import Header from "./Header";
import Footer from "./Footer"
export default class Layout extends React.Component {
render() {
const services = [
{
id: 1,
const Services = () => (
<div>
{services.map(service => (
<div className={service.class}>
<p>{service.id}</p>
<p>{service.name}</p>
</div>
))}
</div>
);
@Kamilnaja
Kamilnaja / react - display item on react component
Last active July 30, 2017 17:09
firstly, you should add lodash
export default class TodosList extends React.Component {
renderItems() {
return _.map(this.props.todos, (todo, index) => <TodosListItem key={index}{...todo} />)
}
render() {
return (
<table>
<TodosListHeader />
<tbody>
class Child extends React.Component {
render () {
return (<div>I'm the child</div>);
}
}
class ShowHide extends React.Component {
constructor () {
super ();
this.state = {
var TimerExample = React.createClass({
getInitialState: function () {
return {elapsed: 0}
},
componentDidMount: function () {
this.timer = setInterval(this.tick, 50);
},
var MenuExample = React.createClass({
getInitialState: function () {
return {focused: 0};
},
clicked: function (index){
this.setState({focused: index})
},
@Kamilnaja
Kamilnaja / child.js
Created September 23, 2017 19:08
send function from one component react
<button onClick={this.props.greet}>Greet</button>
@Kamilnaja
Kamilnaja / angular.js
Created November 1, 2017 21:44
angularJS multiple ctrls
angular.module('myModule', []);
angular.module('myModule').controller('ControllerOne', ['$scope', function($scope) {
}]);
angular.module('myModule').controller('ControllerTwo', ['$scope', function ($scope) {
}])
"scripts": {
"clean": "rimraf dist",
"build": "tsc",
"watch:build": "tsc --watch",
"watch:server": "nodemon './dist/index.js' --watch './dist'",
"start": "npm-run-all clean build --parallel watch:build watch:server --print-label"
},
@Kamilnaja
Kamilnaja / Observer.ts
Created November 25, 2017 22:18
Observer pattern using ts
interface Subject {
registerObserver(o: Observer): void;
removeObserver(o: Observer): void;
notifyObservers(): void;
}
interface Observer {
update(temperature: number): void;
}