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
Basic support for server-side-rendering #969
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This checks if `window` exists before checking `window.navigator` in the default config. Without this check, Flatpickr cannot be loaded in Node.js (for e.g. server-side-rendering the react component). This has a side-effect of disabling animation in non-browser contexts :P I also added a very simple test that just require's the Flatpickr.js source file in node.js. A more comprehensive test would build the dist folder and then require that, but this is probably good enough for now. Note that this test must run outside of Jest, because Jest automatically pollyfills window, which would make it pass even when it shouldn't. This fixes the root cause of the following issues: * haoxins/react-flatpickr#9 * https://github.com/carbon-design-system/carbon-components-react/issues/76
Looks great, thank you for the effort! 👍 👍 |
My pleasure, thanks for the quick response! Can you let me know when it's released so that I can send PRs to update the other two projects? |
@nfriedly Absolutely |
Any chance a release could be published so we can resolve this issue? carbon-design-system/carbon-components-react#150 |
@tw15egan v3.0.7 is out |
@chmln Thanks so much! |
nfriedly
added a commit
to nfriedly/react-flatpickr
that referenced
this pull request
Aug 8, 2017
Fixes haoxins#9 See flatpickr/flatpickr#969 for context.
haoxins
pushed a commit
to haoxins/react-flatpickr
that referenced
this pull request
Aug 9, 2017
Fixes #9 See flatpickr/flatpickr#969 for context.
rajr5
pushed a commit
to rajr5/react-flatpickr
that referenced
this pull request
Jun 23, 2023
Fixes #9 See flatpickr/flatpickr#969 for context.
slava187
pushed a commit
to slava187/react-flatpickr
that referenced
this pull request
Nov 21, 2023
Fixes #9 See flatpickr/flatpickr#969 for context.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This checks if
window
exists before checkingwindow.navigator
when creating the default config.Without this check, Flatpickr cannot even be loaded in Node.js (for e.g. server-side-rendering of the react component).
This has a side-effect of disabling animation in Node.js :P
I also added a very simple test that just runs
require('require('./src/flatpickr.js')
in Node.js. A more comprehensive test might be to build the dist folder and then requiredist/flatpickr.js
, I can switch it if you'd prefer. Note that this test must run outside of Jest, because Jest automatically pollyfillswindow
, which would make it pass even when it shouldn't.This fixes the root cause of the following issues: