Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 为什么Storybook的数组旋钮在更改内容时不更新?_Reactjs_Storybook - Fatal编程技术网

Reactjs 为什么Storybook的数组旋钮在更改内容时不更新?

Reactjs 为什么Storybook的数组旋钮在更改内容时不更新?,reactjs,storybook,Reactjs,Storybook,当我在控制台中看到它时,它确实会更改数组,但不会重新渲染它。所有其他旋钮都可以工作。我使用一个条件来检查主体是否有足够的长度来渲染它 故事: import React from 'react' import moment from 'moment' import { storiesOf } from '@storybook/react' import { text, boolean, select, number, array, date, color as colo

当我在控制台中看到它时,它确实会更改数组,但不会重新渲染它。所有其他旋钮都可以工作。我使用一个条件来检查主体是否有足够的长度来渲染它

故事:

import React from 'react'
import moment from 'moment'
import { storiesOf } from '@storybook/react'
import {
  text,
  boolean,
  select,
  number,
  array,
  date,
  color as colorKnob
} from '@storybook/addon-knobs'
import Article from '@psl/ui/Article'
import ArticleReadMe from '@psl/ui/Article/README.md'

const defaultDate = new Date()

function formattedDateKnob(name, defaultValue) {
  const stringTimestamp = date(name, defaultValue)
  const currentDate = moment(stringTimestamp).format('dddd Do MMMM, YYYY')
  return currentDate
}
const defaultBody = ['First paragraph', 'Second paragraph']

const articleStories = storiesOf('Articles', module)
articleStories
  .addParameters({
    readme: {
      sidebar: ArticleReadMe
    }
  })
  .add('Article', () => {
    const isFetching = boolean('Is fetching?', false)
    const title = text('Title of the article', 'Obesity in premature babies')
    const articleDate = formattedDateKnob('Date', defaultDate)
    const articleBody = array('Body of article', defaultBody)
    const referenceLink = text('Reference link', 'https://link.com')
    const reference = text(
      'Reference',
      'https://meetinglibrary.asco.org/record/185967/abstract'
    )
    const source = text('Source', 'University of Washington School of Medicine')

    console.info(articleBody)
    return (
      <Article
        isFetching={isFetching}
        title={title}
        date={articleDate}
        body={defaultBody}
        referenceLink={referenceLink}
        reference={reference}
        source={source}
      />
    )
  })
渲染该阵列的组件的一部分:

  {body.length &&
    body.map((paragraph, index) => {
      return (
        <Typography type="body1" key={index} className={styles.body}>
          <Markup html={paragraph} />
        </Typography>
      )
    })}
应该这样吗

body={defaultBody}
是这个吗

body={articleBody}