@@ -44,6 +44,11 @@ export default class Markdown extends Component {
4444 rules : ( props , propName , componentName ) => {
4545 let invalidProps = [ ] ;
4646 const prop = props [ propName ] ;
47+
48+ if ( ! prop ) {
49+ return ;
50+ }
51+
4752 if ( typeof prop === 'object' ) {
4853 invalidProps = Object . keys ( prop ) . filter ( key => typeof prop [ key ] !== 'function' ) ;
4954 }
@@ -82,11 +87,11 @@ export default class Markdown extends Component {
8287 markdownParser = null ;
8388
8489 /**
85- * Only when the copy changes will the markdown render again.
86- * @param nextProps
87- * @param nextState
88- * @return {boolean }
89- */
90+ * Only when the copy changes will the markdown render again.
91+ * @param nextProps
92+ * @param nextState
93+ * @return {boolean }
94+ */
9095 shouldComponentUpdate ( nextProps , nextState ) {
9196 const copy = this . getCopyFromChildren ( nextProps . children ) ;
9297
@@ -99,8 +104,8 @@ export default class Markdown extends Component {
99104 }
100105
101106 /**
102- *
103- */
107+ *
108+ */
104109 componentWillMount ( ) {
105110 const { renderer, rules, style, plugins, markdownit } = this . props ;
106111
@@ -125,29 +130,27 @@ export default class Markdown extends Component {
125130 ) ;
126131 }
127132
133+ let md = markdownit ;
128134 if ( plugins && plugins . length > 0 ) {
129- let md = markdownit ;
130-
131135 plugins . forEach ( plugin => {
132136 md = md . use . apply ( md , plugin . toArray ( ) ) ;
133137 } ) ;
134-
135- this . markdownParser = md ;
136138 }
139+
140+ this . markdownParser = md ;
137141 }
138142
139143 getCopyFromChildren ( children = this . props . children ) {
140144 return children instanceof Array ? children . join ( '' ) : children ;
141145 }
142146
143147 /**
144- *
145- * @return {View }
146- */
148+ *
149+ * @return {View }
150+ */
147151 render ( ) {
148152 const copy = ( this . copy = this . getCopyFromChildren ( ) ) ;
149- const { renderer } = this . props ;
150153
151- return parser ( copy , renderer , this . markdownParser ) ;
154+ return parser ( copy , this . renderer , this . markdownParser ) ;
152155 }
153156}
0 commit comments