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
export const Page = ({ posts, scrollToTop }) => ( | |
<div> | |
{posts && posts.map(post => ( | |
<div key={post.title} dangerouslySetInnerHTML={{ __html: post.content }} /> | |
))} | |
<a className="toTop" onClick={scrollToTop} /> | |
</div> | |
); | |
........ |
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
import { branch, renderComponent } from 'recompose'; | |
const Loading = () => ( | |
<div>Loading....</div> | |
); | |
export const withLoadingComponent = branch( | |
props => props.loading, | |
renderComponent(Loading), | |
); |
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
export const Component = ({ data: { loading, ... } }) => { | |
if (loading) { | |
... | |
return(<LoadingComponent>); | |
} | |
... | |
}; |
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
export const Component = () => { | |
const onClickHandler = () => { | |
... | |
}; | |
return ( | |
<div onClick={onClickHandler}></div> | |
); | |
}; |
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
import { compose, withHandlers } from 'recompose'; | |
// Component Code here | |
export default compose( | |
connect(mapStateToProps), | |
graphql(PAGE_QUERY, getOptions(['posts'])), | |
withLoadingComponent, | |
withHandlers(handlers) | |
)(Page); |
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
export const LANG_QUERY = gql` | |
... | |
`; | |
const mapStateToProps = state => ({ | |
language: state.language, | |
}); | |
const mapDispatchToProps = dispatch => ({ | |
changeLang: (lang) => { | |
dispatch(setLanguage(lang)); |