Skip to content

Commit

Permalink
More housekeeping
Browse files Browse the repository at this point in the history
* make fp non-reactive
  • Loading branch information
ankurk91 committed Oct 16, 2022
1 parent 27d4f1b commit cc0efba
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ import {createApp} from 'vue';
import VueFlatPickr from 'vue-flatpickr-component';
import 'flatpickr/dist/flatpickr.css';
// Your app initialization logic goes here
const app = createApp().mount('#app')
const app = createApp({});
app.use(VueFlatPickr);
app.mount('#app');
```

This will register a global component `<flat-pickr>`
Expand Down
20 changes: 6 additions & 14 deletions src/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default defineComponent({
);
}
},
// https://chmln.github.io/flatpickr/options/
// https://flatpickr.js.org/options/
config: {
type: Object,
default: () => ({
Expand All @@ -59,14 +59,7 @@ export default defineComponent({
default: false
}
},
data() {
return {
/**
* The flatpickr instance
*/
fp: null
};
},
fp: null, // non-reactive
mounted() {
// Return early if flatpickr is already loaded
/* istanbul ignore if */
Expand Down Expand Up @@ -206,10 +199,9 @@ export default defineComponent({
},
beforeUnmount() {
/* istanbul ignore else */
if (this.fp) {
this.fpInput().removeEventListener('blur', this.onBlur);
this.fp.destroy();
this.fp = null;
}
if (!this.fp) return
this.fpInput().removeEventListener('blur', this.onBlur);
this.fp.destroy();
this.fp = null;
}
});
2 changes: 1 addition & 1 deletion webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ module.exports = {
}),
new webpack.DefinePlugin({
__VUE_OPTIONS_API__: true,
__VUE_PROD_DEVTOOLS__: false
__VUE_PROD_DEVTOOLS__: true
}),
new VueLoaderPlugin(),
],
Expand Down

0 comments on commit cc0efba

Please sign in to comment.