Skip to content

Commit

Permalink
Update renderContent to receive attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
camillof authored and julianguyen committed Oct 18, 2024
1 parent 0662880 commit 55f1ff0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions client/app/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// @flow
import axios from 'axios';
import renderHTML from 'react-render-html';
import { sanitize } from 'dompurify';
import React from 'react';
import renderHTML from 'react-render-html';

const randomString = (): string => Math.random()
.toString(36)
Expand Down Expand Up @@ -33,10 +34,13 @@ const getPusher = (): Object | null => {
return null;
};

const renderContent = (content: string | any): any => {
const renderContent = (content: string | any, attributes: Object = {}): any => {
if (typeof content === 'string') {
return renderHTML(sanitize(content));
}
if (React.isValidElement(content)) {
return React.cloneElement(content, attributes);
}
return content;
};

Expand Down

0 comments on commit 55f1ff0

Please sign in to comment.