![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
react-mobiledoc-hooks
Advanced tools
yarn add react-mobiledoc-hooks
# or
npm install react-mobiledoc-hooks
useMobiledoc
hookGiven a document in mobiledoc
format, useMobiledoc
renders a React list of its sections. A custom render configuration can be also provided.
// RichText.js
import React from 'react'
import { useMobiledoc } from 'react-mobiledoc-hooks'
// Read more bellow in "Customization"
const configuration = {
atoms: [],
cards: [],
markups: [],
sections: [],
additionalProps: [],
}
function RichText({ doc, ...props }) {
const output = useMobiledoc(doc, configuration)
return (
<div className="richtext" {...props}>
{output}
</div>
)
}
// App.js
import React from 'react'
import RichText from './RichText'
const mobiledoc = {
version: '0.3.1',
atoms: [],
cards: [],
markups: [['strong']],
sections: [
[
1,
'p',
[
[0, [], 0, 'This is a '],
[0, [0], 1, 'useMobiledoc'],
[0, [], 0, ' demo'],
],
],
],
}
function App() {
return <RichText doc={mobiledoc} />
}
The output should look like this:
This is a useMobiledoc demo
The second argument in useMobiledoc
sets some options:
atoms
: array
cards
: array
markups
: array
sections
: array
additionalProps
: object
- Extra props
that will be passed to every atom, section and cardatoms
, cards
, markups
and sections
require array of objects with these attributes:
name
: string
component
: Component|Function
Example for a custom Mention
atom:
// Mentions.js
export default function Mention({username, ...props}) {
return (
<span className="mention" {...props}>
@{username}
</span>
)
}
// RichText.js
import Mention from './Mention'
const configuration = {
atoms: [
{
name: 'mention'
component: Mention
}
]
}
function RichText({ doc, ...props }) {
const output = useMobiledoc(doc, configuration)
return (
<div className="richtext" {...props}>
{output}
</div>
)
}
yarn
To build a production version, run:
yarn build
This library is built using Rollup.js
MIT (see LICENCE file).
© 2019 Stimme der Hoffnung e.V in Germany
FAQs
Collection of React hooks for Mobiledoc
The npm package react-mobiledoc-hooks receives a total of 3 weekly downloads. As such, react-mobiledoc-hooks popularity was classified as not popular.
We found that react-mobiledoc-hooks demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.