Skip to content

practice-react-styling#55

Open
misiek869 wants to merge 6 commits intodevmentor-pl:masterfrom
misiek869:master
Open

practice-react-styling#55
misiek869 wants to merge 6 commits intodevmentor-pl:masterfrom
misiek869:master

Conversation

@misiek869
Copy link

W zadaniu 5 miałem problem. Funkcja onClick wydaje mi się ok, ale nie działa. W pliku TabsItems mam tablice z obiektami, które mają generować tab itemy. Chciałem zrobić to tak aby importować tą tablicę i na niej pracować. Dlatego w plikach mam zakomentowane // import TabsItems from './TabsItems'. Bardzo proszę o podpowiedź jak to zrobić i czy będzie to poprawne :)

Copy link
Owner

@devmentor-pl devmentor-pl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Michale,

Jesteś pewny, że wrzuciłeś wszystko co masz? Brakuje mi paru komponentów ;)

Copy link
Owner

@devmentor-pl devmentor-pl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Michale,

Zmierza to w dobrym kierunku, ale...
Musisz wdrożyć rozwiązania bardziej elastyczne.
W innym wypadku te komponenty nie będą reużywalne.
Za każdym razem musiałbyś tworzyć ich kopie, aby zdefiniować odpowiednie dane.
Postaraj się nanieść poprawki :)

// import TabsItems from './TabsItems'

const Tabs = () => {
const TabsItems = [
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tak to nie może działać. Jeśli chciałbyś mieć w aplikacji 2 taki zakładki (z różną treścią) to jak rozwiążesz ten problem? To muszą być dane pochodzące z zewnątrz czyli przez props.

PS. Możesz do tego wykorzystać props.children: https://react.dev/reference/react/Children

const [items, setActive] = useState(TabsItems)

const onClick = idToActivate => {
console.log(TabsItems)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dlaczego twierdzisz, że klik nie działa? U mnie po kliknięciu pojawia się zawartość w consoli...

<TabsItem data={TabsItems} onClick={onClick}></TabsItem>
</StyledNav>
<StyledDiv>
<TabsText data={TabsItems}></TabsText>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Z tego co widzę to po prostu nie przekazujesz "items"

</Alert>
</Col>
</Row>
)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

<Button>Button!</Button>
</Col>
</Row>
)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

border-radius: 0.25rem;
`

export { StyledBreadcrumb }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}
`

export { StyledBreadcrumbItem }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


const Button = props => {
return (
<ThemeProvider theme={themeSettings}>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Motyw (theme) powinien być poza samym komponent aby można było go definiować dowolnie w każdy aplikacji. W tym przypadku moglibyśmy po prostu go ostylować bez motywu.

}
`

export { StyledButton }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

display: block;
`

export { StyledCol, StyledNav, StyledDiv }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments