diff --git a/04/src/App.js b/04/src/App.js index 2f0262ac..0a96d484 100644 --- a/04/src/App.js +++ b/04/src/App.js @@ -1,12 +1,13 @@ import React from "react"; import "./App.css"; -import Validation from './Validation' +import Validation from "./Validation"; +import Char from "./Char"; class App extends React.Component { constructor(props) { super(props); - this.state = { message: "Sup!" }; + this.state = { message: "" }; } handleChange = event => { @@ -15,17 +16,27 @@ class App extends React.Component { this.setState({ message: newMessage }); }; + handleDelete(index) { + let newSplited = [...this.state.splited] + } + render() { const input = ( // // --> this works this.handleChange(event)} /> // --> but this is better ); + let splited = this.state.message.split(""); + console.log("splited", splited); + return (

{this.state.message}

{input} - + + {splited.map((item, index) => { + return + })}
); } diff --git a/04/src/Char.css b/04/src/Char.css new file mode 100644 index 00000000..78f6ef3e --- /dev/null +++ b/04/src/Char.css @@ -0,0 +1,7 @@ +.Char { + display: inline-block; + padding: 16px; + text-align: center; + margin: 16px; + border: 1px solid black; +} diff --git a/04/src/Char.js b/04/src/Char.js index e69de29b..4b1278d4 100644 --- a/04/src/Char.js +++ b/04/src/Char.js @@ -0,0 +1,14 @@ +import React from "react"; +import "./Char.css"; + +class Char extends React.Component { + constructor(props) { + super(props); + } + + render() { + return
{this.props.string}
; + } +} + +export default Char; diff --git a/04/src/Validation.js b/04/src/Validation.js index 22ac4fc0..88f1668d 100644 --- a/04/src/Validation.js +++ b/04/src/Validation.js @@ -4,13 +4,16 @@ class Validation extends React.Component { constructor(props) { super(props); console.log("Validation:", props); - // console.log(this.props.message.lenght); } render() { return(
-

validation placeholder

+ {this.props.length <= 5 ? +

good enough (length: {this.props.length})

+ : +

TOO MUCH, STAHP (length: {this.props.length})

+ }
) }