-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove params spread, potentially fix #1424
- Loading branch information
Showing
5 changed files
with
70 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import * as React from 'react'; | ||
import {IntlProvider, useIntl, injectIntl, IntlShape} from '../'; | ||
|
||
const Comp: React.FC<{}> = _ => { | ||
const {formatDate} = useIntl(); | ||
return <h1>{formatDate(Date.now())}</h1>; | ||
}; | ||
|
||
const Comp2: React.FC<{intl: IntlShape}> = ({ | ||
intl: {formatDate, formatTime}, | ||
}) => { | ||
return ( | ||
<> | ||
<h1>{formatDate(new Date(), {month: 'long'})}</h1> | ||
<h2>{formatTime(undefined)}</h2> | ||
</> | ||
); | ||
}; | ||
|
||
const Comp2WithIntl = injectIntl(Comp2); | ||
|
||
interface Props { | ||
currentTime?: Date | number; | ||
} | ||
|
||
const App: React.FC<Props> = _ => { | ||
return ( | ||
<IntlProvider locale="en" timeZone="Asia/Tokyo"> | ||
<p> | ||
<Comp /> | ||
<Comp2WithIntl /> | ||
</p> | ||
</IntlProvider> | ||
); | ||
}; | ||
|
||
App.defaultProps = { | ||
currentTime: new Date(), | ||
}; | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>React Intl Explicit Example</title> | ||
</head> | ||
<body> | ||
<div id="timezone"></div> | ||
<div id="messages"></div> | ||
<div id="advanced"></div> | ||
<script src="./index.tsx"></script> | ||
</body> | ||
</html> | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>React Intl Explicit Example</title> | ||
</head> | ||
<body> | ||
<div id="timezone"></div> | ||
<div id="messages"></div> | ||
<div id="advanced"></div> | ||
<div id="injected"></div> | ||
<script src="./index.tsx"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters