react-icons/bs#BsArrowLeft JavaScript Examples
The following examples show how to use
react-icons/bs#BsArrowLeft.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Slideshow.js From viade_en1b with MIT License | 5 votes |
Slideshow = (props) => {
const reducer = (state, action) => {
switch (action.type) {
case "NEXT":
return { picture: state.picture + 1 };
case "PREVIOUS":
return { picture: state.picture - 1 };
default:
return null;
}
};
const [state, dispatch] = useReducer(reducer, { picture: 0 });
const previousButton =
state.picture === 0 ? (
<button
data-testid="previous"
disabled
onClick={() => dispatch({ type: "PREVIOUS" })}
>
<BsArrowLeft></BsArrowLeft>
</button>
) : (
<button
data-testid="previous"
onClick={() => dispatch({ type: "PREVIOUS" })}
>
<BsArrowLeft></BsArrowLeft>
</button>
);
const nextButton =
state.picture === props.images.length - 1 ? (
<button
data-testid="next"
disabled
onClick={() => dispatch({ type: "NEXT" })}
>
<BsArrowRight></BsArrowRight>
</button>
) : (
<button data-testid="next" onClick={() => dispatch({ type: "NEXT" })}>
<BsArrowRight></BsArrowRight>
</button>
);
const pictures =
props.images.length === 0
? "There are no media elements"
: props.images[state.picture];
const buttons =
props.images.length === 0 ? null : (
<div id="slideshow-buttons">
{previousButton}
{nextButton}
</div>
);
return (
<div id="slideshow-container">
<div id="slideshow-photos">
{pictures}
{buttons}
</div>
</div>
);
}