@schibsted/niche-stylizr
v2.1.1
Published
Takes a text and a styles-array and converts it by calling the handlers supplied when creating a stylizr instance.
Downloads
1,653
Maintainers
Keywords
Readme
niche-stylizr
Takes a text and a styles-array and converts it by calling the handlers supplied when creating a stylizr instance.
Usage
// stylizr-instance.js
import React from 'react';
import stylizr from 'stylizr';
const stylizrInstance = stylizr({
'style:em': (text, key) => <em key={key}>{text}</em>,
});
export default stylizrInstance;
// ----
// another-file.js
import React from 'react';
import ReactDOM from 'react-dom';
import stylizr from './stylizr-instance';
ReactDOM.render(
<MyComponent>
{stylizr('This is my text', [
{
offset: 5,
length: 2,
type: 'style:em',
},
])}
</MyComponent>,
document.getElementById('react-root')
);