This is pretty simple, lets dive in!
Find a name that isn't taken and clearly describes what your module is doing
$ npm view your-first-node-module
// prop callback | |
class Compoennt { | |
render() { | |
return ( | |
<div> | |
<Thing onChange={(val) => { | |
this.setState({ val1: val }) | |
}}/> | |
<Thing onChange={(val) => { | |
this.setState({ val2: val }) |
const RadioBtnGroup = React.createClass({ | |
getDefaultProps() { | |
return { | |
options: [] | |
} | |
} | |
handleValueChange(evt) { | |
this.setState({ | |
value: evt.currentTarget.value |
import React, { Component, PropTypes } from 'react'; | |
import popperJS from 'popper.js'; | |
export default class Popper extends Component { | |
constructor(props) { | |
super(props); | |
this.state = {}; | |
this.update = this.update.bind(this); | |
} |
function RadioGroup({ onChange, name, children }) { | |
const [state, inputProps] = useRadioGroup(name) | |
return ( | |
<Context.Provider value={inputProps}> | |
{children} | |
</Context.Provider> | |
) | |
} | |
function RadioInput(props) { |
module.exports = function (plop) { | |
/* Helpers */ | |
plop.addHelper('upperCase', function (text) { | |
return text.toUpperCase(); | |
}); | |
/* Files */ | |
var createIndex = { | |
type: 'add', |
function RemoveAccents(strAccents) { | |
var strAccents = strAccents.split(''); | |
var strAccentsOut = new Array(); | |
var strAccentsLen = strAccents.length; | |
var accents = 'ÀÁÂÃÄÅàáâãäåÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñŠšŸÿýŽž'; | |
var accentsOut = "AAAAAAaaaaaaOOOOOOOooooooEEEEeeeeeCcDIIIIiiiiUUUUuuuuNnSsYyyZz"; | |
for (var y = 0; y < strAccentsLen; y++) { | |
if (accents.indexOf(strAccents[y]) != -1) { | |
strAccentsOut[y] = accentsOut.substr(accents.indexOf(strAccents[y]), 1); | |
} else |
{ | |
"_meta": { | |
"template_version": 0 | |
}, | |
"fixtures": [ | |
{ | |
"name": "startup_product", | |
"path": "/v1/products", | |
"method": "post", | |
"params": { |
const fs = require('fs-extra'); | |
const methods = {}, priv = {}; | |
// Private methods to do string replacement. Not optimized and cummulative trying to keep it simple. | |
// far better options here: https://stackoverflow.com/questions/5069464/replace-multiple-strings-at-once | |
priv.replaceObj = function(value, vars) { | |
let obj = value; | |
Object.keys(obj).forEach(function(item) { | |
obj[item] = priv.replaceStr(obj[item], vars); | |
}); | |
return obj; |
import { useState, useEffect } from 'react'; | |
// Usage | |
function App() { | |
// Call our hook for each key that we'd like to monitor | |
const happyPress = useKeyPress('h'); | |
const sadPress = useKeyPress('s'); | |
const robotPress = useKeyPress('r'); | |
const foxPress = useKeyPress('f'); |