New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot read property 'createLTR' of undefined #137
Comments
I had the same problem; turns out it was a RTFM issue. From the react-dates readme:
|
Same problem here. This did not work: Downgrading to 12.7.0, as @kakadiadarpan mentioned, solved this. The code is there: |
@RayBowman2017b encountered the same issue. Working on the same app! I have downgraded as well! Thank you for posting this here. |
@alexmcmillan Thanks. It worked. |
So you have to downgrade 6 major releases to fix this bug? |
That shouldn’t be necessary. Using the latest version with importing the initialize entry point should work. |
Yes, i had the same issue. But after importing the initialize entry point it has been solve.
|
As @alexmcmillan said, this is required by default because of the dependency with On the other hand, I had the error when trying to run the tests using Jest. I just had to import the initializer at the beginning of the test file and that fixed the issue. Note File: import * as React from "react";
import "jest-styled-components";
import renderer from 'react-test-renderer';
import "react-dates/initialize"; //<===========================================
import MySingleDatePicker from "../MySingleDatePicker";
...
describe("MySingleDatePicker", () => {
it("Should render correctly", () => {
const component = renderer.create(
<MySingleDatePicker
value={null}
/>
).toJSON();
expect(tree).toMatchSnapshot();
});
}); |
I am bundling a component that wraps react-dates into a component library that transpiles to cjs with rollup. The library is consumed by an isomorphic react project. Using |
It’s possible rollup is incorrectly removing code; it wouldn’t be the first time. Can you reproduce it with browserify or webpack? |
Using import 'react-dates/initialize' is working for me. |
I was struggling for a minute there - you need to add the css link too - import 'react-dates/lib/css/_datepicker.css'; Doh! |
Closing; this seems answered. |
I'm running into the same problem. I've got the initializer at the top of the component file, and I'm getting this error: react_1 | TypeError: Cannot read property 'createLTR' of undefined
react_1 | at Object.createLTR (/usr/src/app/node_modules/react-with-styles/lib/ThemedStyleSheet.js:23:47)
react_1 | at getStyleDef (/usr/src/app/node_modules/react-with-styles/lib/withStyles.js:129:61)
react_1 | at getState (/usr/src/app/node_modules/react-with-styles/lib/withStyles.js:147:17)
react_1 | at new WithStyles (/usr/src/app/node_modules/react-with-styles/lib/withStyles.js:168:25)
react_1 | at processChild (/usr/src/app/build/webpack:/node_modules/react-dom/cjs/react-dom-server.node.development.js:2098:1)
react_1 | at resolve (/usr/src/app/build/webpack:/node_modules/react-dom/cjs/react-dom-server.node.development.js:2064:1)
react_1 | at ReactDOMServerRenderer.render (/usr/src/app/build/webpack:/node_modules/react-dom/cjs/react-dom-server.node.development.js:2383:1)
react_1 | at ReactDOMServerRenderer.read (/usr/src/app/build/webpack:/node_modules/react-dom/cjs/react-dom-server.node.development.js:2357:1)
react_1 | at renderToString (/usr/src/app/build/webpack:/node_modules/react-dom/cjs/react-dom-server.node.development.js:2729:1)
react_1 | at /usr/src/app/build/webpack:/render.js:103:1
react_1 | at process._tickCallback (internal/process/next_tick.js:68:7) This is in a server-side rendered application. Is there anything that would prevent either Relevant versions of things: React(-dom): 16.4.2 This is in the dev environment, so it's unlikely to be a tree-shaking issue. |
@tstirrat15 Have you managed to figure this out? Same issue here |
@matthlavacka We're no longer experiencing the issue, but I can't figure out exactly what fixed it - we ran in to this issue, tabled the upgrade for a few months, and when I came back to it, it Just Worked^tm somehow. We're on react 16.10 now, and we're using One thing to check is that you're only pulling one copy of react into your project - |
thanks for your reply @tstirrat15, I decided to use different package to not waste time. |
This comment has been minimized.
This comment has been minimized.
this worked for me
|
I have the same problem that but the code is exactly the same. am using react programming. |
Worked! |
thanks it is work for me |
Nothing need just import thiese 2 lines where you date import above this import these import "react-dates/initialize"; |
it's working thank you. |
I had to remove my node modules and reinstall them. |
I had the same problem here, apparently remove node modules and reinstall them worked. |
Ussing: https://github.com/airbnb/react-dates
server render
Cannot read property 'createLTR' of undefined
TypeError: Cannot read property 'createLTR' of undefined
at Object.createLTR (/usr/src/app/node_modules/react-with-styles/lib/ThemedStyleSheet.js:23:47)
at createStyles (/usr/src/app/node_modules/react-with-styles/lib/withStyles.js:105:59)
at WithStyles.maybeCreateStyles (/usr/src/app/node_modules/react-with-styles/lib/withStyles.js:200:22)
at WithStyles.componentWillMount (/usr/src/app/node_modules/react-with-styles/lib/withStyles.js:134:20)
at u.performInitialMount (/usr/src/app/server.bundle.js:15:553194)
at u.mountComponent (/usr/src/app/server.bundle.js:15:552366)
at Object.mountComponent (/usr/src/app/server.bundle.js:1:96042)
at X.mountChildren (/usr/src/app/server.bundle.js:15:559600)
at X._createContentMarkup (/usr/src/app/server.bundle.js:15:591579)
at X.mountComponent (/usr/src/app/server.bundle.js:15:590247)
at Object.mountComponent (/usr/src/app/server.bundle.js:1:96042)
at X.mountChildren (/usr/src/app/server.bundle.js:15:559600)
at X._createContentMarkup (/usr/src/app/server.bundle.js:15:591579)
at X.mountComponent (/usr/src/app/server.bundle.js:15:590247)
at Object.mountComponent (/usr/src/app/server.bundle.js:1:96042)
at X.mountChildren (/usr/src/app/server.bundle.js:15:559600)
at X._createContentMarkup (/usr/src/app/server.bundle.js:15:591579)
at X.mountComponent (/usr/src/app/server.bundle.js:15:590247)
at Object.mountComponent (/usr/src/app/server.bundle.js:1:96042)
at X.mountChildren (/usr/src/app/server.bundle.js:15:559600)
at X._createContentMarkup (/usr/src/app/server.bundle.js:15:591579)
at X.mountComponent (/usr/src/app/server.bundle.js:15:590247)
The text was updated successfully, but these errors were encountered: