Skip to content

Instantly share code, notes, and snippets.

View rxluz's full-sized avatar

Ricardo Luz rxluz

View GitHub Profile
@rxluz
rxluz / wrappingApp.jsx
Created December 13, 2017 21:08
Wrapping your application with Redux i18n
///.... your other imports
import I18n from 'redux-i18n';
import { translations } from '__src__/config/locales/index';
ReactDOM.render(
<Provider store={store}>
<I18n translations={translations} initialLang="en" fallbackLang="en">
<App />
</I18n>
import React, { Component } from 'react';
import PropTypes from 'prop-types';
/**
* This is an react component that echo an hello world
*/
class SomeReactComponent extends Component {
render() {
return <div> {this.props.title} </div>;
}
{
"scripts": {
"doc": "./docs.sh"
}
}
cd "src"
# find . -type d -print0 | xargs -0 -L1 sh -c 'cd "$0" && pwd && react-doc-generator $0 -o ./$0/README.md'
find . -type d -print0 | xargs -0 -L1 sh -c 'cd "$0" && pwd && react-doc-generator . -o ./README.md'
const save = (id) => {
//your save code here
return {
goToUserProfile: () => window.location.replace(`myurl.example/profile`)
}
};
const save = (id, redirectAfterSave) => {
//your save code here
if(redirectAfterSave) {
window.location.replace(`myurl.example/user/${id}`)
}
return null;
}
const save = (id) => {
//your save code here
return {
goToUserProfile: () => window.location.replace(`myurl.example/profile/${id}`)
}
};
const save = (id) => {
//your save code here
return {
goToUserProfile: (name) =>
confirm(`Hi ${name}, you'd like to be redirected to your page`)
? window.location.replace(`https://myurl.example/profile/${id}`)
: false
}
};
function showNameAndAge(name, age){
return `Hello ${name}, you are ${age} years old`;
}
showNameAndAge('Ricardo', 32); //right
showNameAndAge(32, 'Ricardo'); //wrong
function showNameAndAge({name, age}){
return `Hello ${name}, you are ${age} years old`;
}
showNameAndAge({name: 'Ricardo', age: 32}); //right
showNameAndAge({age: 32, name: 'Ricardo'}); //also right!