Skip to content

Using replace not able to use style #172

Closed
@dev-on2air

Description

@dev-on2air

I'm using following replace to get notified when an image is loaded:

replace: function(domNode) {
            if(domNode.name === 'img'){
                console.log('replacing img', domNode)
                return (
                    <img
                        {
                            ...domNode.attribs
                        }
                        onLoad={() => console.log('image loaded')}
                    />
                )
            }

        }

If the image has a style attribute, when i add it back in via the domNode.attribs it throws an error since its not an style object as expected for the jsx img. its still a string. How can I convert the attributes to be jsx ready to passthru in the replace?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions