Skip to content

Commit ac356ad

Browse files
committed
css modules working
1 parent 5bfe321 commit ac356ad

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

.DS_Store

0 Bytes
Binary file not shown.

firstapp/src/App.js

+27-27
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React, { Component } from 'react';
22
// import './person/person.css';
33
// import './App.css';
4-
import classes from './App.module.css';
4+
import styles from './App.module.css';
55
import Person from './person/Person.js';
6+
67
class App extends Component {
78

89
state = {
@@ -15,6 +16,10 @@ class App extends Component {
1516
showPersons: false
1617
}
1718

19+
componentDidMount = () => {
20+
console.log('App Component Props', this.props);
21+
}
22+
1823
nimiChangedHandler = (event, id) => {
1924
const personIndex = this.state.persons.findIndex(p => {
2025
return p.id === id;
@@ -49,33 +54,28 @@ class App extends Component {
4954
}
5055

5156
render() {
52-
53-
5457
let persons = null;
5558
let btnClass = '';
5659

57-
if(this.state.showPersons){
60+
if (this.state.showPersons) {
5861
persons = (
5962
<div>
60-
{this.state.persons.map((person, index) => {
61-
return <Person
62-
click={() => this.deletePersonHandler(index)}
63-
nimi= {person.nimi}
64-
id= { person.id}
65-
key={person.id }
66-
changed={(event) => this.nimiChangedHandler(event, person.id)}
67-
68-
69-
/>
70-
})}
71-
63+
{ this.state.persons.map((person, index) => {
64+
return (
65+
<Person
66+
click={() => this.deletePersonHandler(index)}
67+
nimi={person.nimi}
68+
id={person.id}
69+
key={person.id }
70+
changed={(event) => this.nimiChangedHandler(event, person.id)}
71+
/>
72+
);
73+
})}
7274
</div>
7375
);
74-
75-
76-
77-
btnClass = classes.Red;
78-
console.log('btnClass:',btnClass);
76+
btnClass= styles.Red;
77+
//btnClass = classes.Red;
78+
console.log('btnClass:',btnClass,'styles.App:',styles.App);
7979
}
8080

8181
const classes = [];
@@ -89,20 +89,20 @@ class App extends Component {
8989
}
9090

9191

92+
console.log('Print Styles', styles);
93+
console.log('Classes', classes);
9294

9395
return (
94-
95-
<div className="App">
96+
<div className={styles.App}>
9697
<h1>tekstiä</h1>
97-
<p className = {classes.join(' ')}>lisää tekstiä</p>
98+
<p className={classes.join(' ')}>lisää tekstiä</p>
9899

99100
<button
100-
className={classes.Red}
101-
onClick={this.togglePersonsHandler}> 'Toggle Persons'
101+
className={btnClass}
102+
onClick={this.togglePersonsHandler}> 'Toggle Persons'
102103
</button>
103104
{persons}
104105
</div>
105-
106106
);
107107

108108
}

0 commit comments

Comments
 (0)