Draft-js: Nullthrows error when defining custom blockType in blockStyleFn

Created on 15 Jul 2016  路  3Comments  路  Source: facebook/draft-js

Hi,

How can I define custom block types like native DraftJS block types?

I tried using custom blockStyleFn and it looks like this:
const getBlockStyle = (block) => { switch(block.getType()) { case 'alignRight': return 'editor-align-right'; case 'blockquote': return 'editor-blockquote'; default: return null; }; };

However, I am getting nullthrows error, when alignRight blockType is passed to this function, but blockquote native DraftJS blockType works just fine.

I searched the repo and I thought that this PR should have fixed the issue, since it was merged into current 0.7.0 version.

Any help or advice on how to accomplish what I am looking for would be greatly appreciated! Thanks!

Most helpful comment

Really? It's been 12 hours.

All 3 comments

Is anyone paying attention to the problems of users on this repo at all?

Really? It's been 12 hours.

Check out the docs here about setting blockRenderMap: https://github.com/facebook/draft-js/pull/387/files.

Was this page helpful?
0 / 5 - 0 ratings