Last active
June 25, 2018 10:31
-
-
Save levvsha/71ad7150d9d441ddde6ecb21ea596de6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
constructor() { | |
... | |
this.getEditorState = () => this.state.editorState; | |
this.blockRendererFn = customBlockRenderer( | |
this.onChange, | |
this.getEditorState | |
); | |
} | |
... | |
const customBlockRenderer = (setEditorState, getEditorState) => (contentBlock) => { | |
const type = contentBlock.getType(); // <-- [1] | |
switch (type) { | |
case 'SLIDER': | |
return { | |
component: EditorSlider, // <-- [2] | |
props: { | |
getEditorState, // <-- [3] | |
setEditorState, // <-- [3] | |
} | |
}; | |
default: return null; | |
} | |
}; | |
const RenderMap = new Map({ // <-- [4] | |
SLIDER: { | |
element: 'div', // <-- [5] | |
} | |
}).merge(DefaultDraftBlockRenderMap); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment