-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from divar-ir/add-ssr-sample
Add SSR sample
- Loading branch information
Showing
3 changed files
with
42 additions
and
15 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,43 @@ | ||
import React from 'react'; | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import MetaTags from 'react-helmet'; | ||
|
||
import logo from 'src/assets/logo.svg'; | ||
|
||
import { getHomeTitle } from './requests'; | ||
|
||
import './Home.scss'; | ||
|
||
function Home() { | ||
return ( | ||
<main className="container home"> | ||
<MetaTags title="divar-starter-kit 🚀" /> | ||
<img | ||
className="home__logo" | ||
src={logo} | ||
alt="divar-stater-kit" | ||
/> | ||
<p className="title">Running divar-starter-kit successfully.</p> | ||
</main> | ||
); | ||
class Home extends Component { | ||
static serverSideInitial() { | ||
const title = getHomeTitle(); | ||
|
||
return { | ||
title, | ||
}; | ||
} | ||
|
||
render() { | ||
const { initialSSRData: { title } } = this.props; | ||
|
||
return ( | ||
<main className="container home"> | ||
<MetaTags title="divar-starter-kit 🚀" /> | ||
<img | ||
className="home__logo" | ||
src={logo} | ||
alt="divar-stater-kit" | ||
/> | ||
<p className="title">{title}</p> | ||
</main> | ||
); | ||
} | ||
} | ||
|
||
Home.propTypes = { | ||
initialSSRData: PropTypes.shape({ | ||
title: PropTypes.string, | ||
}).isRequired, | ||
}; | ||
|
||
export default Home; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
// eslint-disable-next-line import/prefer-default-export | ||
export function getHomeTitle() { | ||
return 'Running divar-starter-kit successfully.'; | ||
} |