`message.contentType` is a string but `codecFor` expects an object
fabriguespe opened this issue · comments
Describe the bug
In the reactSDK (as well as in the JS SDK) codecFor
expects a contenType object.
/**
* Find a matching codec for a given `ContentTypeId` from the
* client's codec registry
*/
codecFor(contentType: ContentTypeId): ContentCodec<any> | undefined;
Yet in the reactSDK the message.contentType
returns a string, making codecFor
return undefined
Expected behavior
No response
Steps to reproduce the bug
No response
thanks for reporting this! yes, in the React SDK, we use/store contentType
as a string. to convert back to an object for use in codecFor
, use the ContentTypeId.fromString
static method.
const contentType = ContentTypeId.fromString(message.contentType);
const codec = xmtpClient.codecFor(contentType);
Thks! Updated the docs snippet
xmtp/xmtp-dot-org#680