Skip to content

Commit d22204c

Browse files
committed
feat: add render props
1 parent 44f05bd commit d22204c

File tree

9 files changed

+7706
-0
lines changed

9 files changed

+7706
-0
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Learn React with TypeScript
1010
- [Goal](https://github.com/locol23/learn-react-typescript/tree/master/packages/function-components-goal)
1111
- Styled Components
1212
- [Base & Goal](https://github.com/locol23/learn-react-typescript/tree/master/packages/styled-components)
13+
- Advanced Techniques
14+
- [Base](./packages/render-props-base)
1315
- Recompose
1416
- State(withStateHandlers)
1517
- [Base](https://github.com/locol23/learn-react-typescript/tree/master/packages/recompose-state-base)

packages/render-props-base/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# render props
2+
3+
[React Advanced Guides](https://reactjs.org/docs/render-props.html)

packages/render-props-base/package-lock.json

+7,617
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "render-props-base",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"clean": "rimraf dist",
8+
"parcel:dev": "parcel src/index.html",
9+
"parcel:prod": "parcel build src/index.html",
10+
"dev": "run-s clean parcel:dev",
11+
"build": "run-s clean parcel:prod",
12+
"storybook": "start-storybook -p 6006",
13+
"build-storybook": "build-storybook"
14+
},
15+
"keywords": [],
16+
"author": "Yoshitaka Terazawa <[email protected]> (https://twitter.com/locol23)",
17+
"license": "MIT",
18+
"devDependencies": {
19+
"npm-run-all": "^4.1.5",
20+
"parcel-bundler": "^1.12.4",
21+
"rimraf": "^3.0.2",
22+
"typescript": "^3.8.3"
23+
},
24+
"dependencies": {
25+
"react": "^16.13.1",
26+
"react-dom": "^16.13.1"
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from 'react'
2+
import { Child } from './Child'
3+
4+
export const App: React.FC = () => {
5+
const render = () => <div>render props</div>
6+
7+
return (
8+
<>
9+
<Child render={render} />
10+
<Child />
11+
</>
12+
)
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import React, { ReactNode } from 'react'
2+
3+
type Props = {
4+
render?: () => ReactNode
5+
}
6+
7+
export const Child: React.FC<Props> = ({ render }) => <>{render ? render() : <p>render is nothing</p>}</>
8+
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>React Typescript Boilerplate</title>
6+
</head>
7+
<body>
8+
<div class="app">Loading...</div>
9+
<script src="index.tsx"></script>
10+
</body>
11+
</html>
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import React from 'react'
2+
import ReactDOM from 'react-dom'
3+
import { App } from './components/App'
4+
5+
ReactDOM.render(<App />, document.querySelector('.app'))
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"module": "commonjs",
5+
"lib": ["dom", "es2020"],
6+
"allowJs": false,
7+
"jsx": "react",
8+
"removeComments": true,
9+
"noEmit": false,
10+
"strict": true,
11+
"noUnusedLocals": true,
12+
"noUnusedParameters": true,
13+
"noImplicitReturns": true,
14+
"noFallthroughCasesInSwitch": true,
15+
"allowSyntheticDefaultImports": true,
16+
"esModuleInterop": true,
17+
"forceConsistentCasingInFileNames": true
18+
}
19+
}

0 commit comments

Comments
 (0)