arqex / react-datetime

A lightweight but complete datetime picker react component.
1.99k stars 872 forks source link

moment.tz is not a function | moment-timezone is installed as a dependency #734

Open royalidrees53 opened 3 years ago

royalidrees53 commented 3 years ago

As per docs I have installed moment-timezone in my project but still getting moment.tz is not a function. Error occurring when I am using the prop displayTimeZone.

Project Tech: React.JS | ROR | Webpacker

arqex commented 3 years ago

Are you sure you are importing at least once from moment-timezone. Here's an example on how use it

https://codesandbox.io/s/happy-snowflake-gbo1b?file=/src/App.js:0-272

import * as React from "react";
import "react-datetime/css/react-datetime.css";
import Datetime from "react-datetime";
import moment from "moment-timezone";

export default function App() {
  return <Datetime displayTimeZone="America/Los_Angeles" value={new Date()} />;
}
helmerdavila commented 3 years ago

Could it be the bundler @arqex? I tried the same order as the example but it didn't work

moazam996 commented 3 years ago

Hi @arqex @arqex @arqex @arqex i have also tried this but not working for me as well, i'm using Storybook for demo my standalone component with some customization but displayTimeZone is not working. any quick response would be appreciated .

RiinaVi commented 1 year ago

I was having TypeError: a.a.tz is not a function error as well. Deleting and reinstalling dependencies solved it