Skip to content

Instantly share code, notes, and snippets.

View pk936's full-sized avatar
🎯
Focusing

Piyush Kumar pk936

🎯
Focusing
View GitHub Profile
import React from "react";
export default class ShareTask extends React.Component {
constructor(props) {
super(props);
this.state={
shareWithUsers:[],
showUsers:false
}
@pk936
pk936 / comp.jsx
Created July 6, 2017 06:39
Get updated state in componentdidmount ?
/**
* Created by piyush on 23/6/17.
*/
import React from 'react';
import Select from '../../common/ui/select.js'
export default class Close_Task_Modal extends React.Component{
constructor(props){
super(props);
this.state= {
@pk936
pk936 / file.js
Created July 4, 2017 04:55
Get updated props of the child implemented using ReactDOM.render.
class Parent extends React.Component{
constructor(props){
super(props)
}
open(){
let _this = this;
var _html = '<div class="collapsible-body" id="'+eleId+'"></div>';
taskdetail = ReactDOM.render(<TaskDetail data={_this.props.data}/>, document.getElementById(eleId)); // Child "TaskDetail" does not get updated props.
export default class CreateTask extends Component {
constructor(props){
super(props);
this.state = {
checkBoxValues:false
}
this.handleSubmit = this.handleSubmit.bind(this);
}
onChange(e){
@pk936
pk936 / gist:cc1720a9cf79f7c89966d9540f3ba710
Created May 22, 2017 10:43
input field is freeze here even I can see the name in the texfield. Can't edit why ?
render(){
let name = this.state.name;
return (
<input vaue={name} /> // input field is freeze here even I can see the name in the texfield. Can't edit why ?
)
}
var arr = [];
var temp = 10; // says temp is unused
arr(
{
temp: { // here temp is not recognised
a: 10
}
}
)
{(
()=>{
if(fromOperatorFields.length > 0){
return (
fromOperatorFields.map((fields,index)=>{
return <option key={index} value="">{fields.label}</option>
})
)
}
}
{(
() => {
if(fromOperatorFields.length > 0) {
return <option value="">Select Label</option>
}
}
)()}
@pk936
pk936 / gist:5832c517314267fc85fe1b1b28cc9185
Created May 18, 2017 06:07
I want to access custom attribute in option tag in select
render(){
return (<select id="selectTemplate" ref={(input) => this.templateSelect = input}>
<option value="0" disabled selected>Select Template</option>
{(
()=>{
console.log("Templates", this.props.templates)
return this.props.templates.templates.data.map((template, index) => {
console.log("template.id::::::::::", template.id) // fine
return <option key={template.id} value={template.attributes.name}>{template.attributes.name}</option>