-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'next' into menulist-tabindex
- Loading branch information
Showing
8 changed files
with
127 additions
and
88 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,24 @@ | ||
import React from 'react'; | ||
import { MemoryRouter as Router } from 'react-router'; | ||
import { Link } from 'react-router-dom'; | ||
import Button from '@material-ui/core/Button'; | ||
|
||
// required for react-router-dom < 6.0.0 | ||
// see https://github.com/ReactTraining/react-router/issues/6056#issuecomment-435524678 | ||
const AdapterLink = React.forwardRef((props, ref) => <Link innerRef={ref} {...props} />); | ||
|
||
const HomeLink = React.forwardRef((props, ref) => <Link innerRef={ref} to="/home" {...props} />); | ||
|
||
function App() { | ||
return ( | ||
<Router> | ||
<Button color="primary" component={AdapterLink} to="/"> | ||
Root | ||
</Button> | ||
{/* Avoids property collision */} | ||
<Button component={HomeLink}>Home</Button> | ||
</Router> | ||
); | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from 'react'; | ||
import { MemoryRouter as Router } from 'react-router'; | ||
import { Link, LinkProps } from 'react-router-dom'; | ||
import Button from '@material-ui/core/Button'; | ||
|
||
// required for react-router-dom < 6.0.0 | ||
// see https://github.com/ReactTraining/react-router/issues/6056#issuecomment-435524678 | ||
const AdapterLink = React.forwardRef<HTMLAnchorElement, LinkProps>((props, ref) => ( | ||
<Link innerRef={ref as any} {...props} /> | ||
)); | ||
|
||
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>; | ||
const HomeLink = React.forwardRef<HTMLAnchorElement, Omit<LinkProps, 'innerRef' | 'to'>>( | ||
(props, ref) => <Link innerRef={ref as any} to="/home" {...props} />, | ||
); | ||
|
||
function App() { | ||
return ( | ||
<Router> | ||
<Button color="primary" component={AdapterLink} to="/"> | ||
Root | ||
</Button> | ||
{/* Avoids property collision */} | ||
<Button component={HomeLink}>Home</Button> | ||
</Router> | ||
); | ||
} | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react'; | ||
import Switch from '@material-ui/core/Switch'; | ||
|
||
function Switches() { | ||
const [state, setState] = React.useState({ | ||
checkedA: true, | ||
checkedB: true, | ||
}); | ||
|
||
const handleChange = (name: string) => (event: React.ChangeEvent<HTMLInputElement>) => { | ||
setState({ ...state, [name]: event.target.checked }); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<Switch checked={state.checkedA} onChange={handleChange('checkedA')} value="checkedA" /> | ||
<Switch | ||
checked={state.checkedB} | ||
onChange={handleChange('checkedB')} | ||
value="checkedB" | ||
color="primary" | ||
/> | ||
<Switch value="checkedC" /> | ||
<Switch disabled value="checkedD" /> | ||
<Switch disabled checked value="checkedE" /> | ||
<Switch defaultChecked value="checkedF" color="default" /> | ||
</div> | ||
); | ||
} | ||
|
||
export default Switches; |
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
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