Provide a more explanatory example project
See original GitHub issueHi, thanks for your work.
I spent hours trying to customise a property in the list without any success, and I’d like some pointers.
My project uses
- nest.js
- typescript
- adminBro
I’m following the docs to the letter. In the configuration I added:
{ resource: styleModel, options: {
properties: {
parentId: {
components: {
list: AdminBro.bundle('./components/reference-in-list'),
},
}
}
} },
My ./components/reference-in-list is defined as the following:
import React from 'react'
import { InputGroup, Label } from '@admin-bro/design-system'
import { BasePropertyProps } from 'admin-bro'
const ReferenceInList: React.FC<BasePropertyProps> = (props) => {
const { record, property } = props
const value = record.params[property.name]
return (
<InputGroup>
<Label>{property.name}</Label>
{value}
</InputGroup>
)
}
export default ReferenceInList
All I got is an error:
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Is there any special configuration to add when using adminBro with nest.js? There are no docs on your website for using your product with nest.js and the example-app is very basic.
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (2 by maintainers)
Top Results From Across the Web
Write a Project Description with Examples | Smartsheet
1. Describe the project in a paragraph or two. 2. Why is it necessary? 3. Follow the SMART goal format.
Read more >How to Write an Explanatory Essay: Topics, Outline, Example
Wonder how to write an explanatory essay? Click for the full guide that contains an explanatory essay example for your help.
Read more >Explanatory Research | Definition, Guide, & Examples - Scribbr
Explanatory research is a research method that explores why something occurs when limited information is available.
Read more >How to Write a Project Charter, with Examples [2022] • Asana
Give project stakeholders a clear sense of your main objectives and ... Your project plan builds on your project charter to provide a...
Read more >Explanatory Research: Types, Examples, Pros & Cons
2. Literature research: Literature research involves examining and reviewing existing academic literature on a topic related to your projects, ...
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 Free
Top 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

After a bit more investigation I figured out why this wasn’t woking and how to get it to work.
What I originally failed to realise is that
AdminBro.bundleexpects the uncompiled component (in my case the.tsxfile). I will say that again as it is not what I expected:AdminBro.bundleexpects the uncompiled component filesBy using
component: AdminBro.bundle('./components/company-index')it was finding the files in thedistfolder where thetsxhas been compiled bynestjs/tscintojs- this resultingjsis not compatible withAdminBro.bundle. It is trying to use the version ofreactfrom the server not the browser!By using
component: AdminBro.bundle('../../../src/components/company-index')it was finding the files in thesrcfolder where the uncompiledtsxfile can be found and can be compiled and bundled byAdminBro.bundle. This is fine on my local dev environment … but not so good on the server (wheresrcdoes not exist).To fix this I had to setup
nestjsto copy thetsxcomponent files to thedistfolder without compiling them, that wayAdminBro.bundlecan compile them and bundle them up correctly for use in the browser.Here are the steps I followed to achieve this:
Update
nest-cli.jsoncompilerOptions.assetsto copy thetsxcomponent files from myadmin-panel/componentsfolder insrc:Updated
tsconfigto excludesrc/admin-panel/components(you need do this intsconfig.build.jsontsconfig.jsondepending on your setup )You also don’t need
"jsx": "react",in thetsconfigcompilerOptionsif you are not compiling anytsxfiles withnestjs,Finally I updated my
AdminBro.bundlepaths to be relative (without../../srcas suggested by @SimonB407 - which although it didn’t work I would never have figured this out without this hint so thanks again)Hope this helps someone else.
Thanks to @maxpeterson , I resolved the issue I had with user components not being bundled in prod build.
If anyone else is struggling with bundling of custom components in production, you can use my commit here as a reference.
If you’re struggling with nestjs+adminjs setup in general, I guess, you can use my repo for reference too. It’s not very clean and there is only one entity hooked up, but it should clear some things up, if you’re struggling.