TypeError: action.default is not a function
See original GitHub issueI have created a new route that works perfectly fine when I navigate to it from a different route via the Link
Component but when I enter the url in the browser and open the page directly all I get is this TypeError
:
TypeError: action.default is not a function
at context.route.load.then.action ([....]/src/router.js:16:1)
I don’t really get what it’s trying to tell me.
My routes.js
(the swiper route fails)
const routes = {
path: '/',
// Keep in mind, routes are evaluated in order
children: [
{
path: '/',
load: () => import(/* webpackChunkName: 'home' */ './home'),
},
{
path: '/swiper',
load: () => import(/* webpackChunkName: 'swiper' */ './swiper'),
},
// Wildcard routes, e.g. { path: '*', ... } (must go last)
{
path: '*',
load: () => import(/* webpackChunkName: 'not-found' */ './not-found'),
},
],
async action({ next }) {
// Execute each child route until one of them return the result
const route = await next();
// Provide default values for title, description etc.
route.title = `${route.title || 'Untitled Page'} - x`;
route.description = route.description || '';
return route;
},
};
And the swiper/index.js
route:
function action() {
return {
chunks: ['swiper'],
title: 'Swiper',
component: (
<Layout>
<Swiper />
</Layout>
),
};
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
TypeError: action.default is not a function - Stack Overflow
First, check what is present in then((action). add check if (action && action.default === 'function'). if it is true then call the function...
Read more >TypeError: "x" is not a function - JavaScript - MDN Web Docs
The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value...
Read more >is not a function or its return value is not iterable in ReactJs ...
React Nodejs Expressjs & MongoDB bug fixing. TypeError : default is not a function or its return value is not iterable in ReactJs...
Read more >'X' is not a function TypeError in React [Solved] | bobbyhadz
Another common reason the "Uncaught TypeError: X is not a function" error occurs in React is when we try to call a function...
Read more >How to Handle JavaScript Uncaught TypeError: “x” is Not a ...
The Javascript error TypeError: "x" is not a function occurs when there is an attempt to call a function on a value or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
swiper/index.js
must exportaction
fn:@damiangreen I am using react-quill lib, and when I use that component it is showing me the same error, for my other component page is rendering but only for this component it’s showing this error.