A
A
Alexey2021-02-16 17:51:04
React
Alexey, 2021-02-16 17:51:04

Is it safe to send html markup to render react.createElement?

Good evening)
An object is stored on the server in the form:

const text = {
    'type': 'h1',
    'props': {
        'key': 1
    },
    'element':  'Заголовок'
}


And sent to the client when requesting
React, having received this object, renders html markup

export default function test () {
 return React.createElement(
    text.type,
    text.props,
    text.element
   )
}


The idea is to store some kind of ready-made html structure in the database and send it to the client when necessary. Further, this data object is converted to a normal form using React.createElement
no longer figured out how to convert a text file from the server into code ...
The essence of the question is: is it safe to do this and how is this type of code perceived by experienced programmers?)
I just- only self-taught without familiar programmers

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question