File tree Expand file tree Collapse file tree
src/components/portfolioPage Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,7 +14,12 @@ class Corpora extends Component {
1414 } ;
1515
1616 sort = memoize ( ( items , criteria ) => items . sort ( by ( `${ criteria } .0` ) ) ) ;
17-
17+
18+ componentWillReceiveProps ( props ) {
19+ this . setState ( {
20+ listCorpus : props . ids
21+ } )
22+ }
1823 render ( ) {
1924 let itemsData = this . sort ( this . props . items , this . state . criteria ) ;
2025 let items = itemsData . map ( x =>
@@ -24,8 +29,9 @@ class Corpora extends Component {
2429 let options = this . _getOptions ( attributes ) ;
2530 let count = this . props . items . length ;
2631 let total = this . props . from ;
27- let listIds = this . props . ids . map ( ( corpus ) =>
28- < div key = { corpus } > < input type = "checkbox" value = { corpus } onChange = { this . handleChange } /> { corpus } < ItemCreator corpus = { corpus } conf = { this . props . conf } /> </ div >
32+ let listIds = this . props . ids . map ( ( corpus ) => {
33+ return < div key = { corpus } > < input type = "checkbox" value = { corpus } onChange = { this . handleChange } /> { corpus } < ItemCreator corpus = { corpus } conf = { this . props . conf } /> </ div > ;
34+ }
2935 ) ;
3036 return (
3137 < div className = "col-md-8 p-4" >
@@ -68,15 +74,14 @@ class Corpora extends Component {
6874 handleChange = ( e ) => {
6975 let list = this . state . listCorpus ;
7076 let index = list . indexOf ( e . target . value ) ;
71- if ( index != - 1 ) {
77+ if ( index !== - 1 ) {
7278 list . splice ( index , 1 ) ;
7379 } else {
7480 list . push ( e . target . value ) ;
7581 }
7682 this . setState ( {
7783 listCorpus : list
7884 } ) ;
79- console . log ( 'this.state=' , this . state ) ;
8085 }
8186}
8287
You can’t perform that action at this time.
0 commit comments