Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. class SomeReactComponent extends React.Component {
  2. constructor(props) {
  3. super(props);
  4. ...
  5. }
  6.  
  7. ...
  8.  
  9. render() {
  10. return (
  11. <span>
  12. <p>Text that should be displayed to anyone!</p>
  13. { Meteor.userId() ? (
  14. <button id="btn">
  15. This button is only available to logged in users
  16. </button>
  17. ) : ""}
  18. </span>
  19. );
  20. }
  21. }
  22.  
  23. import React from "react";
  24. import {createContainer} from "meteor/react-meteor-data";
  25.  
  26. class SomeReactComponent extends React.Component {
  27. constructor(props) {
  28. super(props);
  29.  
  30. }
  31.  
  32.  
  33.  
  34. render() {
  35. return (
  36. <span>
  37. <p>Text that should be displayed to anyone!</p>
  38. { this.props.authenticated ? (
  39. <button id="btn">
  40. This button is only available to logged in users
  41. </button>
  42. ) : ""}
  43. </span>
  44. );
  45. }
  46. }
  47. export default createContainer(()=>{
  48. return {
  49. authenticated: Meteor.userId(),
  50. }
  51. },SomeReactComponent);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement