Quickstart
A quick dive into getting started with Lore
A quick dive into getting started with Lore
In this step we'll use react-router
to convert the title in the header to a clickable link that will always take the user back to the homepage. We won't make use of the functionality in this Quickstart, but it's a good practice to follow.
You can view the finished code for this step by checking out the
routing.1
branch of the completed project.
Open the Header
component and find this line:
// src/components/Header.js
<div className="navbar-brand">
Lore Quickstart
</div>
Next, import the Link
tag from react-router
and update the code to look like this:
// src/components/Header.js
import { Link } from 'react-router';
...
<Link className="navbar-brand" to="/">
Lore Quickstart
</Link>
In the code above, we've converted the div
tag into a clickable link, and set the to
property to the root URL (/
). Now whenever you click the link, you'll be taken back to the homepage.
If everything went well, your application will look the same visually, but now the title in the header will be a clickable link that takes you back to the homepage.
Below is a list of files modified during this step.
import React from 'react';
import createReactClass from 'create-react-class';
import PropTypes from 'prop-types';
import { Link } from 'react-router';
export default createReactClass({
displayName: 'Header',
render() {
return (
<nav className="navbar navbar-default navbar-static-top header">
<div className="container">
<div className="navbar-header">
<Link className="navbar-brand" to="/">
Lore Quickstart
</Link>
</div>
</div>
</nav>
);
}
});
import React from 'react';
import PropTypes from 'prop-types';
import { Link } from 'react-router';
class Header extends React.Component {
render() {
return (
<nav className="navbar navbar-default navbar-static-top header">
<div className="container">
<div className="navbar-header">
<Link className="navbar-brand" to="/">
Lore Quickstart
</Link>
</div>
</div>
</nav>
);
}
}
export default Header;
import React from 'react';
import PropTypes from 'prop-types';
import { Link } from 'react-router';
class Header extends React.Component {
render() {
return (
<nav className="navbar navbar-default navbar-static-top header">
<div className="container">
<div className="navbar-header">
<Link className="navbar-brand" to="/">
Lore Quickstart
</Link>
</div>
</div>
</nav>
);
}
}
export default Header;
Next we're going to create a Feed
component for displaying tweets and add it to the routes.