change style programmatically react native code example
Example: react native how to change programmatically view style
const Sample3 = (props) => {
const [dir, setDirection] = useState("row");
return (
<div
style={{
display: "flex",
flexDirection: "dir",
alignItems: "center",
width: 150,
height: 250,
backgroundColor: "grey",
justifyContent: "flex-start",
flexWrap: "wrap",
}}
>
<button
onClick={() => {
if (dir === "row") {
setDirection("column");
} else {
setDirection("row");
}
}}
>
Click
</button>
</div>
);
};