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

Table.Column not updating label prop when it's updated. #359

Closed
merisbahti opened this issue Aug 5, 2020 · 3 comments
Closed

Table.Column not updating label prop when it's updated. #359

merisbahti opened this issue Aug 5, 2020 · 3 comments
Assignees
Labels
type: bug Something isn't working

Comments

@merisbahti
Copy link

merisbahti commented Aug 5, 2020

Bug report 🐞

Version & Environment

  • Chrome latest
  • Version of zeit-ui/react: ^1.8.0-canary.0

Expection

When using a table like this:

() => {
  const data = [
    { property: 'type', description: 'Content type', type: 'secondary | warning', default: '-' },
    { property: 'Component', description: 'DOM element to use', type: 'string', default: '-' },
    { property: 'bold', description: 'Bold style', type: 'boolean', default: 'true' },
  ]
  const [state, setState] = React.useState(0)
  React.useEffect(() => {
    const interval = setInterval(() => {
      setState((old) => old + 1)
    }, 1000)
    return () => {
      clearInterval(interval)
    }
  }, [])
  return (
    <Table data={data}>
      <Table.Column prop="property" label="property" />
      <Table.Column prop="description" label={`description: ${state}`} />
      <Table.Column prop="type" label="type" />
      <Table.Column prop="default" label="default" />
    </Table>
  )
}

The description label prop is not being updated. This is a "minimal" reproducable example, I'm not doing exactly this in my application.

Actual results (or Errors)

The description label prop isn't being updated, even though the variable state is being updated.

@unix unix self-assigned this Aug 6, 2020
@unix unix added the type: bug Something isn't working label Aug 6, 2020
@unix
Copy link
Member

unix commented Aug 9, 2020

@merisbahti The pre-release version v1.8.0-canary.9 is out now, it should solve this issue.

@merisbahti
Copy link
Author

Interesting, thanks. In a way, it does solve the issue, however it's not super obvious to me.

For example, this still does not work:

() => {
  const data = [
    { property: 'type', description: 'Content type', type: 'secondary | warning', default: '-' },
    { property: 'Component', description: 'DOM element to use', type: 'string', default: '-' },
    { property: 'bold', description: 'Bold style', type: 'boolean', default: 'true' },
  ]
  const [state, setState] = React.useState(0)
  React.useEffect(() => {
    const interval = setInterval(() => {
      setState((old) => old + 1)
    }, 1000)
    return () => {
      clearInterval(interval)
    }
  }, [])
  return (
    <Table data={data}>
      <Table.Column prop="description">
        Description: {state}
      </Table.Column>
    </Table>
  )
}

However, if you stringify the state in the label, like this:

      <Table.Column prop="description" label={state}>
        Description: {state}
      </Table.Column>

it updates as expected. Is this expected?

@unix
Copy link
Member

unix commented Aug 11, 2020

Sorry, this is my negligence.
I created an online example using version 1.8.0-canary.10, the table children should be sync correctly now.

@unix unix closed this as completed Aug 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants