Ask questionsonMount Error: Function called outside component initialization
I have read sveltejs/sapper#592 but all of the solutions are not working. Is there any solution to fix this issue?
<script>
import { onMount } from 'svelte';
let myVar = [];
onMount(async () => {
myVar = await {someAPICall};
})
</script>
Answer
questions
jackylee941130
Sorry, I have found the problem in my webpack.config.js. '.mjs' must be included in the extensions field.
resolve: {
extensions: ['.mjs', '.js', '.svelte', '.json']
},
module: {
{
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto',
loader: 'babel-loader
}
]
}
Related questions