Comments (10)
Hi @nzayatz14,
you need to use the as parameter.
This is described here: https://chatscope.io/storybook/react/?path=/story/documentation-recipes--page#changing-component-type-to-allow-place-it-in-container-slot
and here: #12
from chat-ui-kit-react.
Ahh interesting, thank you.
For anyone that may come across this while struggling with the as
prop in typscript, here's an example of how to add this prop to your component: https://gist.github.com/kripod/4434e7cecfdecee160026aee49ea6ee8
You could also just pass the as
prop as a string type but then you will not have any checking for if your string is a valid ElementType
from chat-ui-kit-react.
@supersnager so after digging into this a bit, it looks like your getChildren function is relying on the code to not be minified. However, the ConversationHeader
and InputToolbox
get minified on the production build, whereas the MessageList
and MessageInput
components do not. I believe this has something to do with MessageList
and MessageInput
being class based and ConversationHeader
and InputToolbox
being function based components.
Heres an example of the minified vs unminified classes:
Minified ConversationHeader
component:
Non-minified MessageInput
component:
So, in your getChildren function when you are looping through the types
to get the strTypes
here:
var strTypes = types.map(function (t) {
return t.name || t.displayName;
});
Your result is not quite what you'd expect:
Not sure how you want to move forward with this information, but what I've seen from most packages that have specified child props is they will throw a warning on the development build saying something like This is not a valid child element of MyComponent, expecting MyChildComponent or MySecondChildComponent
. But on the production build, they will just ignore it and let it happen, not remove items that are not "supposed to be there."
Hope this helps
from chat-ui-kit-react.
Another heads up that may be related to this @supersnager. I noticed that when I build for production, it looks like the custom components I have do not show up. I created separate components for my conversation header and input container of my chat.
The dev build looks like:
Whereas the production build shows:
Any ideas? I feel like the components may be doing something wonky with the getChildren function and Typescript may be having some issues with it.
from chat-ui-kit-react.
Hey @nzayatz14,
it's difficult to say without the code, but I have some suspicions.
If you are using the as parameter with the type:
as={ConversationHeader}
try to use a string instead:
as="ConversationHeader"
from chat-ui-kit-react.
I actually passing the string currently. Heres a skeleton of my component
<ChatContainer>
<ChatHeader
as='ConversationHeader'
//other props
/>
//MessageList and messages
<ChatInputToolbox
as='InputToolbox'
//other props
/>
</ChatContainer>
from chat-ui-kit-react.
@nzayatz14 How you build your app for production? You are using CRA or something else?
from chat-ui-kit-react.
Yes, just using create-react-app so pretty standard I'd imagine. Also heres my tsconfig if this helps
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"baseUrl": "."
},
"include": [
"src"
]
}
from chat-ui-kit-react.
@nzayatz14 Please check the 1.8.1 version, and let me know if it works for you.
from chat-ui-kit-react.
@supersnager this appears to fix the production build issue, thanks!
from chat-ui-kit-react.
Related Issues (20)
- MessageGroup.Footer with Avatar looks odd
- Expose onKeyPress for MessageInput
- Allow using send button when there is no message text HOT 3
- Scroll to message on browser-native find
- Regarding Chat Reply UI of one another user HOT 1
- IOS 16 version issue of clicking button as Message.CustomContent HOT 3
- Unexpected overflow on ChatContainer HOT 2
- transitionning between the chatcontainer and the sidebar in mobile display HOT 3
- Simple styling with tailwind
- Unexpected width and height change inside components in Message.HtmlContent. HOT 1
- [HELP] How to use the streaming message feature? HOT 4
- Not working on Next.js HOT 4
- Bug: unable to use scroll bar when using custom css HOT 1
- The requested module '/node_modules/prop-types/index.js' does not provide an export named 'default' HOT 1
- Getting started!
- Warning from FontAwesomeIcon about using defaultProps
- Set message input value from another component HOT 1
- Is there a way to actually set a proper max-length for MessageInput? HOT 1
- Avatar isn't displayed when custom content is used
- Sass deprecation warning
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chat-ui-kit-react.