Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c82b5ee

Browse files
19 - Inheritance & Reusable Functions in React
1 parent 4276f4d commit c82b5ee

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

‎src/App.js‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import React, { Component } from 'react'
22
// import PostSorting from './posts/PostSorting'
3-
import Timer from './learn/Timer'
43
import './App.css'
54

5+
import WelcomeHereDialog, {AlertBox, SubItem} from './learn/ParentWrapper'
6+
67
class App extends Component {
78
render () {
89
return (
910
<div className='App'>
10-
<Timer startCount='1000' />
11+
<AlertBox alertType='danger'>I think this is working...</AlertBox>
12+
<WelcomeHereDialog />
1113
</div>
1214
)
1315
}

‎src/learn/ParentWrapper.js‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React, {Component} from 'react'
2+
3+
// class ParentWrapper extends Component {
4+
// render () {
5+
// const {alertType} = this.props
6+
// return <div className={'alert alert-' + alertType}>{this.props.children}</div>
7+
// }
8+
// }
9+
10+
function AlertBox (props) {
11+
return <div className={'alert alert-' + props.alertType}>{props.children}</div>
12+
}
13+
14+
function WelcomeHereDialog () {
15+
return <AlertBox alertType='success'><h1>Some new content</h1></AlertBox>
16+
}
17+
18+
class SubItem extends Component {
19+
render () {
20+
return <AlertBox alertType='success'><h1>Some new content</h1></AlertBox>
21+
}
22+
}
23+
24+
export {AlertBox, SubItem}
25+
export default WelcomeHereDialog

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /