First of all read the whole post, secondly install Create React App globally and create an app using create-react-app my-app, then before any coding add packages to your app. As soon as you finish all package installations you can start coding using my basics code snippets if you need to 🙂
Add main React package to your enviroment
Create React App
npm i -g create-react-app
This will allow you to create React Apps with no build configuration anywhere in your computer.
create-react-app my-app
cd my-app/
npm start
This will create a React App called my-app pointing to http://localhost:3000/, any time you save your files your app will be updated automatically.
Link to the library.
Add packages to your React app
Within my-app folder.
Bootstrap
npm i -S bootstrap
npm i -S react-bootstrap
npm i -S react-router-bootstrap
This will allow us to use this front-end framework in a easier way (with React).
Links to the library.
For example lets code our home page (home.js)
import React from 'react';
import { Grid, Row, Col, Jumbotron, Image } from 'react-bootstrap';
import people from '../media/people.png';
function Home(props) {
const t = props.t; // we will pass the translation function via props
return (
<div>
<Grid>
<Jumbotron>
<h1>{t('Open knowledges')}</h1>
<p>Cool text right here</p>
</Jumbotron>
</Grid>
<Grid>
<Row>
<Col lg={12}>
<p>I love paragraphs.</p>
<p>I love paragraphs.</p>
</Col>
</Row>
<Row>
<Col lg={12}>
<p>I love paragraphs.</p>
<Image className="detached" src={people} responsive />
</Col>
</Row>
</Grid>
</div>
);
}
export default Home;
Anything that you would use repeatedly in other pages of your website should be in a different file (component), such as the navigation bar and the footer. Create a layout component to organize your components all together (layout.js)
import React, { Component } from 'react';
import Navigation from '../components/Navigation';
import Footer from '../components/Footer';
class Layout extends Component {
render() {
return (
<div>
<Navigation t={this.props.t}></Navigation>
{this.props.children}
<Footer></Footer>
</div>
);
}
}
export default Layout;
React Router
npm i -S react-router
npm i -S react-router-dom
This will make our website’s routing easier.
Link to the library.
Let’s create our website/app (index.js) with two pages, for example Home (home.js) and About (about.js)
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter, Route } from 'react-router-dom';
import './index.css';
import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap/dist/css/bootstrap-theme.css';
import Layout from './pages/Layout';
import Home from './pages/Home';
import About from './pages/About';
import i18n from './i18n';
let t = i18n.t.bind(i18n); // for translations
ReactDOM.render(
<BrowserRouter>
<div>
<Route exact path="/" render={() => <Layout t={t}><Home t={t} /></Layout>} />
<Route exact path="/about" render={() => <Layout t={t}><About t={t} /></Layout>} />
</div>
</BrowserRouter>,
document.getElementById('root')
);
Add i18next package
npm i -S i18next
This will let us do our website/app internationalization.
Link to the library.
import i18n from 'i18next';
i18n
.init({
fallbackLng: 'en',
lng: navigator.language.split('-')[0],
debug: true,
resources: {
en: {
translation: {
"Hello": "Hola",
"Bye": "Adiós"
}
}
}
});
export default i18n;
Futher details using i18n in this post: Create a multilingual React website.
How your files structure would look like?
.
+-- _components
| +-- Footer.css
| +-- Footer.js
| +-- Navigation.css
| +-- Navigation.js
+-- _media
| +-- logo.svg
+-- _pages
| +-- Layout.js
| +-- Home.js
| +-- About.js
+-- i18n.js
+-- index.css
+-- index.js
Create an universal React app
/in CSS3, HTML5, JavaScript, Tooling/by GénesisFirst of all read the whole post, secondly install Create React App globally and create an app using create-react-app my-app, then before any coding add packages to your app. As soon as you finish all package installations you can start coding using my basics code snippets if you need to 🙂
Add main React package to your enviroment
Create React App
npm i -g create-react-app
This will allow you to create React Apps with no build configuration anywhere in your computer.
create-react-app my-app
cd my-app/
npm start
This will create a React App called my-app pointing to http://localhost:3000/, any time you save your files your app will be updated automatically.
Link to the library.
Add packages to your React app
Within my-app folder.
Bootstrap
npm i -S bootstrap
npm i -S react-bootstrap
npm i -S react-router-bootstrap
This will allow us to use this front-end framework in a easier way (with React).
Links to the library.
For example lets code our home page (home.js)
Anything that you would use repeatedly in other pages of your website should be in a different file (component), such as the navigation bar and the footer. Create a layout component to organize your components all together (layout.js)
React Router
npm i -S react-router
npm i -S react-router-dom
This will make our website’s routing easier.
Link to the library.
Let’s create our website/app (index.js) with two pages, for example Home (home.js) and About (about.js)
Add i18next package
npm i -S i18next
This will let us do our website/app internationalization.
Link to the library.
Futher details using i18n in this post: Create a multilingual React website.
How your files structure would look like?
We are hiring
/in Uncategorized/by GénesisWe are hiring, looking for a Junior Full-Stack Developer in Málaga!
Someone who loves open/free technologies/knowledge, willing to learn new things.
In a first stage, tasks about Web/Phone apps with Javascript and Desktop apps with Qt in C++
The employee will be promoted to Senior Full-Stack Developer and she/he will be able to work with embedded devices and even microcontrollers using C, Smart Networks (using the IoT), Linux clouds and so on.
Linux, C++, Javascript, Qt, HML5, CSS3, MySQL, MariaDB, PostgreSQL, MongoDB, Android, iOS, C, Cordova, Git, Node, Python, Bash, Haskell, Rust
Create a multilingual React website
/in CSS3, HTML5, JavaScript/by GénesisFirst of all create a react app ready to go
create-react-app MY-WEBSITE
This will create a react app with everything configured.
npm start
Add i18next package
npm i -S i18next
This will let us do our website/app internationalization.
Set up your I18next file
Create a i18n.js file in the src folder with this code:
Finally, indicate which text you want to translate
Import your i18n.js and use its t function to indicate where it should be the internationalization.
Dealing with keystores and passwords when building for Android with Cordova
/in JavaScript/by GénesisWhich is the easiest way of builing apps in Android with Cordova?
Use a build.json file
And type in your console: cordova build android –release
If you already have a keystore and don’t know what alias to use, run the command: keytool -list -v -keystore YOUR_KEYSTORE_FILE to see all the available aliases.
Keystore only has one password. You can change it using keytool: keytool -storepasswd -keystore MY_KEYSTORE
Note: I’m locating my build.json and keystore_file in my project’s root folder.
Scroll into view
/in CSS3, JavaScript/by GénesisI have created n boxes (divs) with random colors to select one of them randomly and make it visible on the viewport. Every time you rerun the code you will see in your screen the selected box regardless of its position.