Guest User

Untitled

a guest
May 22nd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. import * as React from 'react';
  2. import styles from './Solid.module.scss';
  3. import { ISolidProps } from './ISolidProps';
  4. import { escape } from '@microsoft/sp-lodash-subset';
  5. import { IQuotes, IQuote } from './QuoteContracts';
  6. import { IDataReader, DataReaderFactory } from './DataReader';
  7. import { ISolidState } from './ISolidState';
  8.  
  9.  
  10. export default class Solid extends React.Component<ISolidProps, ISolidState> {
  11.  
  12. constructor() {
  13. super();
  14. this._dataReader = DataReaderFactory.getReader(this.context);
  15. }
  16.  
  17. private _dataReader : IDataReader;
  18.  
  19. public render(): React.ReactElement<ISolidProps> {
  20. return (
  21. <div className={ styles.solid }>
  22. <div className={ styles.container }>
  23. <div className={ styles.row }>
  24. <div className={ styles.column }>
  25. <span className={ styles.title }>Welcome to SharePoint!</span>
  26. <p className={ styles.subTitle }>Customize SharePoint experiences using Web Parts.</p>
  27. <p className={ styles.description }>{escape(this.props.description)}</p>
  28. <a href="https://aka.ms/spfx" className={ styles.button }>
  29. <span className={ styles.label }>Learn more</span>
  30. </a>
  31. {this.renderQuotes()}
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36.  
  37. );
  38. }
  39.  
  40. fetchData = () => {
  41. this._dataReader.getData().then((response) => {
  42. this.setState({
  43. quotes: response.Quotes,
  44. });
  45. });
  46. }
  47.  
  48. componentDidMount() {
  49. this.fetchData();
  50. }
  51.  
  52. renderQuotes = () => this.state.quotes.map(quote => (
  53. <div>${escape(quote.Quote)}</div>
  54. <div class="${styles.author}">${escape(quote.Author)}</div>
  55. );
  56.  
  57. }
Add Comment
Please, Sign In to add comment