Skip to content

Instantly share code, notes, and snippets.

View vtno's full-sized avatar
👾
building

Tino Thamjarat vtno

👾
building
View GitHub Profile
@vtno
vtno / comment_section1.html
Last active February 1, 2016 19:17
Real Time Comment
<div class = "content"></div>
<script type = "text/babel">
var CommentBox = React.createClass({
render: function(){
return (
<div className=”commentBox”>
Yo! I’m a comment box.
</div>
);
}
var CommentBox = React.createClass({
render: function(){
return (
<div className="commentBox">
<h1>Comments</h1>
<CommentList />
<CommentForm />
</div>
);
}
@vtno
vtno / comment_section2.html
Last active February 1, 2016 19:23
Real Time Comment
var CommentList = React.createClass({
render: function() {
return (
<div className="commentList">
Test Test I'm a CommentList.
</div>
);
}
});
var CommentForm = React.createClass({
var Comment = React.createClass({
render: function(){
return(
<div className="comment">
<h2 className="commentAuthor">
{this.props.author}
</h2>
{this.props.children}
</div>
);
@vtno
vtno / comment_section5.html
Created February 1, 2016 20:18
Real Time Comment
var CommentList = React.createClass({
render: function() {
return (
<div className="commentList">
<Comment author="Mr.Tony">This is the best comment app ever.</Comment>
<Comment author="Obamha">Love this thing.</Comment>
</div>
);
}
});
var data = [
{id:1, author:"Mr.Tony", text:"This is the best comment app ever."},
{id:2, author:"Obhama", text: "Love this thing."}
];
class CommentList extends React.Component{
render() {
var commentNodes = this.props.data.map(function(comment){
return (
<Comment author={comment.author} key = {comment.id}>
function howVarWorks()
{
//i is also visible here.
for( var i = 0 ; i<10 ;i++)
{
//i is visible everywhere in the function
}
//i is also visible here.
}
Meteor.startup(()=>{
let server = Meteor.npmRequire('http').createServer()
let io = Meteor.npmRequire('socket.io')(server)
io.on('connection', (socket)=>{
socket.on('hello',(data)=>{
console.log('HELLO BISH')
console.log(data.text)
})
})
server.listen(9999,()=>{
@vtno
vtno / client.js
Last active April 29, 2016 09:50
Template.home.events({
//some code here....
socket = io.connect('localhost:9999', {forceNew: true})
//more code here......
})
@vtno
vtno / example.jsx
Created March 29, 2017 09:17
Passing new props to this.props.children
export default Class {
constructor(props) {
this.state = {
userRole: 'doctor'
}
}
render(){
const childrenWithProps = React.Children.map(this.props.children,