How about if DraftEntity.get is deprecated?
I get a warging with the latest draft-js.
WARNING: DraftEntity.get will be deprecated soon!
Please use "contentState.getEntity" instead.
If so, it seems impossible to get a Entify in blockRendererFn.
How to handle it?
The blockRendererFn only receives a block as a parameter and returns a component. You should not need the Entity in blockRendererFn. If you need data in your block in order to render something specific, don't rely on the Entity but use Modifier.setBlockData that you can access with block.getData() instead (data in the block instead of being in the entity).
If you want to access an Entity, you have to be in the rendered component returned by blockRendererFn where contentState will be passed as a prop.
You can access your Entity by:
const entity = contentState.getEntity(block.getEntityAt(0))
See https://draftjs.org/docs/advanced-topics-block-components.html
@jebarjonet Thanks for the recommendation.
I see some Entity.get in draft-js-plugins, so I want to know how draft-js-plugins will handle this.
Today I merged a PR upgrading to the latest Draft.js version including the API update. This will be available in Beta10 馃檶
Most helpful comment
Today I merged a PR upgrading to the latest Draft.js version including the API update. This will be available in Beta10 馃檶