postData = (url = '', data = {}, fetchmethod = 'POST', fetchmode) => {
const esc = encodeURIComponent;
var query = Object.keys(data)
.map(k => esc(k)+ '=' + esc(data[k]))
.join('&');
return fetch(url, {
method: fetchmethod, // *GET, POST, PUT, DELETE, etc.
mode: fetchmode, // no-cors, cors, *same-origin
cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
renderSectionOnState = () =>{
switch(this.state.activeSection){
case 'introsection':
return <IntroScreen
handleSwitchSection={this.handleSwitchSection}
activeSection={this.state.activeSection} />
break;
case 'basicinfosection':
return
updateFieldValue = e => {
this.setState({
[e.target.name]: e.target.value
});
};
If nested:
const fs = require(‘fs’).promises;
async function cat(filenmz) {
for (var filenm of filenmz) {
let data = await fs.readFile(filenm, ‘utf8’);
await new Promise((resolve, reject) => {
process.stdout.write(data, ‘utf8’, (err) => {
if (err) reject(err);
else resolve();
});
var myObj = {
a:2,
b:3
}
Object.defineProperty( myObj, Symbol.iterator, {
enumerable: false,
writable: false,
configurable: true,
const withAmount = currencyComponents =>
class Amount extends Component {
constructor(props) {
super(props);
this.state = {
amount: 0,
};
}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git clone --depth=1 https://github.com/react-boilerplate/react-boilerplate.git myapp | |
cd myapp | |
npm run setup | |
npm run clean | |
npm install | |
npm i react-motion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create-react-app myapp | |
cd myapp/src | |
mkdir containers routes utils views | |
touch config.js contexts.js | |
mv App.* routes | |
sed -i '' -e 's/.\/App/.\/routes\/App/g' index.js |
function maxChar(str) {
const charMap = {};
let max = 0;
let maxChar = '';
for (let char of str) {
if (charMap[char]) {
charMap[char]++;
function chunk(array, size) {
const chunked = [];
let index = 0;
while (index < array.length) {
chunked.push(array.slice(index, index + size));
index += size;
}