JavaScript momentjs - fromNow() method in universal (isomorphic) js app

I have an application which is built with node.js and react.js and is universal (or "isomorphic" as they were called before) and speaks with REST API to get data.

In render method of some component I'm displaying date in format like 2 days ago or few seconds ago and with this case moment.js works perfectly. I'm talking about its' method fromNow(), for example:

render() {
  const { date } = this.props;
  const formattedDate = moment(date).fromNow();

  return (
    <div>{formattedDate}</div>
  );
}

But here is the problem:

Warning: React attempted to reuse markup in a container but the
checksum was invalid. This generally means that you are using server
rendering and the markup generated on the server was not what the
client was expecting. React injected new markup to compensate which
works but you have lost many of the benefits of server rendering.
Instead, figure out why the markup being generated is different on the
client or server:
(client) 0:0.2.1.0.1.0.3.2">14 minutes ago</div>
(server) 0:0.2.1.0.1.0.3.2">17 minutes ago</div>

I assume that server time and client time might be different and that causes the problem. What will be the best solution in this case? Maybe it's worth to format date on API side and not on the application's? Your ideas?

Thanks!

Answer:1

I am using owl-carousel which is working pretty good when I load items directly. Although, when I try to load items through AJAX, those been rendered but not been displayed properly and not even ...

I am using owl-carousel which is working pretty good when I load items directly. Although, when I try to load items through AJAX, those been rendered but not been displayed properly and not even ...

  1. carousel doesn't slide
  2. carousel doesn't work
  3. carousel doesn't work bootstrap 4
  4. carousel doesn't start automatically
  5. bootstrap carousel doesn't work
  6. carousel does not resize
  7. bootstrap carousel doesn't slide
  8. owl carousel doesn't work
  9. bootstrap carousel doesn't slide automatically
  10. owl carousel doesn't show
  11. slick carousel doesn't work
  12. wallpaper carousel doesn't work
  13. materialize carousel doesn't work
  14. my carousel doesn't slide
  15. the carousel doesn't stop turning
  16. bootstrap carousel doesn't stop on hover
  17. owl carousel doesn't loop
  18. diptyque carousel doesn't work
  19. carousel slider doesn't work
  20. bootstrap carousel doesn't work angular

I created network in vis.js, but I need add icon to node, for example "plus", and then add handler to this icon. How I can do this?

I created network in vis.js, but I need add icon to node, for example "plus", and then add handler to this icon. How I can do this?

  1. nodejs icon
  2. nodes icon tweak - xf2
  3. xfa nodes icon tweak
  4. lymph nodes icon
  5. music notes icon
  6. server nodes icon
  7. music notes icon vector
  8. user coins icon
  9. node icon tweak
  10. xfa nodes icon tweak 3.0.0
  11. icon nodes mind map
  12. icon treeview nodes

I have one array called data I need to display each values of data array in a div.This is my function function myFunction(data) { var result = ""; for (var i = 0; i < data.length; i++) ...

I have one array called data I need to display each values of data array in a div.This is my function function myFunction(data) { var result = ""; for (var i = 0; i < data.length; i++) ...

I want to merge this array using or || operator [[true,false,false],[false,false,false],[false,false,true]] so that the output is [true,false,true] is this possible with map or reduce or similar? ...

I want to merge this array using or || operator [[true,false,false],[false,false,false],[false,false,true]] so that the output is [true,false,true] is this possible with map or reduce or similar? ...

  1. javascript merge multiple arrays
  2. javascript merge multiple objects
  3. javascript merge multiple arrays of objects
  4. javascript merge multiple arrays without duplicates
  5. javascript merge multiple documents
  6. merge multiple javascript into one
  7. merge multiple javascript files into one
  8. merge multiple javascript
  9. javascript merge multiple files