- Read carefully the README of the project
Done!
- Search if your answer has already been answered in old issues
Done!
I got a little used React-Router-Config's technology:
matchRoutes(routes, url).map(({route, match}) => {
let {getInitData} = route.component; // component's static method
return getInitData instanceof Function
? getInitData(match, store)
: Promise.resolve(null)
});
console.log(route.component) //
{ '$$typeof': Symbol(react.forward_ref),
render: [Function],
preload: [Function] }
Is it possible to access the component's static method getInitData, dynamically imported by loadable-components in routes?
No - an underlying component is not actually loaded at this moment, but would be in a future, when you render a loadable wrapper around it.
If you want to keep using this pattern(I also very like it) - extract “getInitData” to a separate file.
Then:
const component=loadable(()=>import(...);
component.getInitData = getInitData;
And it should work on the server?
interesting solution..
Thanks!
Hello @valorloff, @theKashey solution is good, it should work.
Most helpful comment
No - an underlying component is not actually loaded at this moment, but would be in a future, when you render a loadable wrapper around it.
If you want to keep using this pattern(I also very like it) - extract “getInitData” to a separate file.
Then: