Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spread ChakraProvider props to Provider Component #150

Merged
merged 3 commits into from
Dec 24, 2021

Conversation

Ibby-devv
Copy link
Contributor

Closes #137

Description

Spread built in ChakraProviderProps to Provider Component.

@changeset-bot
Copy link

changeset-bot bot commented Dec 22, 2021

🦋 Changeset detected

Latest commit: 7525f80

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@web3-ui/components Minor
@web3-ui/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@with-heart
Copy link
Member

This makes me wonder if we should just get rid of the Provider component entirely until we have a reason for it. It's not doing anything except wrapping ChakraProvider.

@@ -1,8 +1,8 @@
import React from 'react';
import { ChakraProvider } from '@chakra-ui/react';
import { ChakraProvider, ChakraProviderProps } from '@chakra-ui/react';

export interface ProviderProps {}
Copy link
Member

Choose a reason for hiding this comment

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

For some reason the GitHub suggestions interface is bugging out when I try to select multiple lines so I'll have to spread the suggestions across multiple comments 😬

Since we're already using interface here, we can use extends to clean this up a bit.

Suggested change
export interface ProviderProps {}
export interface ProviderProps extends ChakraProviderProps {}


export interface ProviderProps {}

export const Provider: React.FC<ProviderProps> = ({ children }) => {
return <ChakraProvider>{children}</ChakraProvider>;
export const Provider: React.FC<ProviderProps & ChakraProviderProps> = ({ children, ...props }) => {
Copy link
Member

Choose a reason for hiding this comment

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

Then we don't need to use an intersection here since the type is already tied into ProviderProps.

Suggested change
export const Provider: React.FC<ProviderProps & ChakraProviderProps> = ({ children, ...props }) => {
export const Provider: React.FC<ProviderProps> = ({ children, ...props }) => {

@Ibby-devv
Copy link
Contributor Author

This makes me wonder if we should just get rid of the Provider component entirely until we have a reason for it. It's not doing anything except wrapping ChakraProvider.

Agree, not sure what the Provider is used for. If we need the ChakraProvider, why not just use it directly?

@Dhaiwat10
Copy link
Member

This makes me wonder if we should just get rid of the Provider component entirely until we have a reason for it.

If we don't have a Provider that basically wraps everything inside the ChakraProvider, anyone wanting to use our library properly would have to install and set up Chakra UI themselves. I don't think we would want that.

@Dhaiwat10
Copy link
Member

If we need the ChakraProvider, why not just use it directly?

That's what we are doing! We're just indirectly shipping it as our own provider. We're assuming that not everyone using this package needs to be educated about Chakra.

@Dhaiwat10 Dhaiwat10 merged commit f0c96df into Developer-DAO:main Dec 24, 2021
@github-actions github-actions bot mentioned this pull request Dec 24, 2021
@Ibby-devv
Copy link
Contributor Author

If we need the ChakraProvider, why not just use it directly?

That's what we are doing! We're just indirectly shipping it as our own provider. We're assuming that not everyone using this package needs to be educated about Chakra.

What I meant was our Provider could simply use the ChakraProvider directly until we have something more to add to it.

@Dhaiwat10
Copy link
Member

@Ibby-devv that's precisely what it's doing right now, I think. I am aware that we could just directly export the ChakraProvider as our own Provider but I prefer having a separate file and declaration like this. Purely my opinion though.

@Ibby-devv
Copy link
Contributor Author

@Ibby-devv that's precisely what it's doing right now, I think. I am aware that we could just directly export the ChakraProvider as our own Provider but I prefer having a separate file and declaration like this. Purely my opinion though.

Yeah that's fair enough. I'm on my phone so not sure if the changes I made were what you were looking for in terms of passing on the props to our component.

@Dhaiwat10
Copy link
Member

I merged them in, they're fine!

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.

Accept any props that a ChakraProvider accepts into our components <Provider />
3 participants