Reputation: 43
I'm passing a prop to control an opacity of text, and I can see the prop is passed, but somehow it doesn't work on CSS part. Here's the code
import React from 'react'
import { NavLink } from 'react-router-dom'
import styled from 'styled-components'
//——*——*——*——*——*——//
const Logo = props => {
const { hide } = props
return (
<StyledLogo>
<LogoGroup>
<NavLink to="/" className="logo">
seungmee lee{hide}
</NavLink>
<HideText>
is <br />
an experience designer, <br />
creating and visualizing new experiences
</HideText>
</LogoGroup>
</StyledLogo>
)
}
const StyledLogo = styled.div`
width: 100vw;
background-color: transparent;
color: white;
z-index: 999;
& p:hover {
opacity: 1;
}
& .logo {
font-weight: 600;
float: left;
font-size: 1.2em;
z-index: 100;
}
`
const LogoGroup = styled.div`
position: absolute;
top: 3vw;
left: 3vw;
`
const HideText = styled.p`
font-size: 1.2em;
transition: 0.4s;
opacity: ${props => props.hide};
`
export default Logo
import React from 'react'
// import { BrowserRouter as Router, Route } from 'react-router-dom'
// 1. Dependencies
// 2. Components
// 3. for style
import { Tab, Tabs, TabList, TabPanel } from 'react-tabs'
import styled from 'styled-components'
import WorksCard from '../components/WorksCard'
import Logo from '../components/Logo'
import WORKLIST from '../screens/work-list.json'
import EXPERIMENTLIST from '../screens/experiment-list.json'
// 4. Static Resources
//——*——*——*——*——*——//
const Works = () => {
return (
<div>
<Logo hide={0.5} />
<StyledWorks>
.......
</StyledWorks>
</div>
)
}
.....
export default Works
I could test if the value of 'hide' is passed by including it in text, but when I use it here >> opacity: ${props => props.hide}; it is not applied on actual css.
I'm not sure what is causing the issue. It seems like a basic question, but I couldn't figure out when I checked similar questions.
Upvotes: 0
Views: 1124
Reputation: 123
You must send props to the tag. like,
<HideText hide={hide}>
is <br />
an experience designer, <br />
creating and visualizing new experiences
</HideText>
FIR: props are sent via the tag
Upvotes: 1