-
-
Notifications
You must be signed in to change notification settings - Fork 938
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(useToaster): fix the container parameter of
toaster.push
does n…
…ot work
- Loading branch information
Showing
6 changed files
with
141 additions
and
51 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
50 changes: 50 additions & 0 deletions
50
docs/pages/components/toaster/fragments/custom-container.md
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,50 @@ | ||
<!--start-code--> | ||
|
||
```js | ||
import React from 'react'; | ||
import { useToaster, ButtonToolbar, SelectPicker, Button } from 'rsuite'; | ||
|
||
const Toast = React.forwardRef((props, ref) => { | ||
const { type, placement, duration, children, onClose, ...rest } = props; | ||
|
||
return ( | ||
<div | ||
ref={ref} | ||
{...rest} | ||
style={{ padding: 10, background: '#fff', borderRadius: 4, marginTop: 10 }} | ||
> | ||
{children} | ||
<hr /> | ||
<button onClick={onClose}>Close</button> | ||
</div> | ||
); | ||
}); | ||
|
||
const App = () => { | ||
const toaster = useToaster(); | ||
const container = React.useRef(); | ||
|
||
return ( | ||
<div ref={container}> | ||
<Button | ||
onClick={() => | ||
toaster.push( | ||
<Toast> | ||
<h4>Custom Toast</h4> | ||
<p>This is a custom toast with a close button.</p> | ||
</Toast>, | ||
{ container: () => container.current } | ||
) | ||
} | ||
appearance="primary" | ||
> | ||
Push | ||
</Button> | ||
</div> | ||
); | ||
}; | ||
|
||
ReactDOM.render(<App />, document.getElementById('root')); | ||
``` | ||
|
||
<!--end-code--> |
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