Skip to main content
100%

React SVG element monkeypatch

✓ Published0🌍 Public
Aakre54
Last edited Mar 27, 2015
Created on Mar 23, 2015

This example demonstrates a React technique for rendering SVG filter effects, specifically Gaussian blur, by patching React’s SVG property configuration. It shows how to enable support for the `mask`, `filter`, and `stdDeviation` attributes, which React’s default DOM property whitelist omits. The code imports ReactDOM, ReactElement, and SVGDOMPropertyConfig from React’s internal libraries, then marks these properties as `MUST_USE_ATTRIBUTE`. It also creates custom React factories for the `<filter>` and `<feGaussianBlur>` SVG elements, allowing them to be used as JSX components. The patch runs conditionally based on development mode, using `ReactElementValidator.createFactory` in development and `ReactElement.createFactory` in production.

AI-generated description

Similar vizzes