How to use effector-react - 10 common examples

To help you get started, we’ve selected a few effector-react examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zerobias / effector / website / editor / src / flow / view.js View on Github external
export const TypeErrorsView = () => (
  
    
      <ul>
        {useList(typeErrors, error =&gt; {
          // TODO: hide libdefs until errors are fixed
          if (
            process.env.NODE_ENV === 'production' &amp;&amp;
            error.message[0].loc?.type === 'LibFile'
          )
            return null

          return (
            <li>
              {error.message.map((message, key) =&gt; (
                
              ))}
              {error.extra &amp;&amp;
                error.extra.map((extra, key) =&gt; )}
            </li>
          )</ul>
github zerobias / effector / examples / react-ssr / src / lambda.ts View on Github external
export default async(req, res) => {
  const url = req.url.replace('/ssr', '').replace(/^\//, '')
  if (url === '') {
    const routes = Object.keys(users)
    const route = routes[(Math.random() * routes.length) | 0]
    res.setHeader('Location', `/${route}`)
    res.status(302).send('')
    return
  }
  if (!users.hasOwnProperty(url)) {
    res.status(404).send('not found')
    return
  }
  try {
    const scope = await fork(app, {
      start: startServer,
      ctx: users[url],
    })
    const data = serialize(scope)
    const content = renderToString(React.createElement(App, {root: scope}))
    const result = await compile({content, data})
    res.send(result)
  } catch (err) {
    console.error(err)
    res.status(500).send('something going wrong')
  }
}
github zerobias / effector / examples / react-ssr / src / lambda.ts View on Github external
const routes = Object.keys(users)
    const route = routes[(Math.random() * routes.length) | 0]
    res.setHeader('Location', `/${route}`)
    res.status(302).send('')
    return
  }
  if (!users.hasOwnProperty(url)) {
    res.status(404).send('not found')
    return
  }
  try {
    const scope = await fork(app, {
      start: startServer,
      ctx: users[url],
    })
    const data = serialize(scope)
    const content = renderToString(React.createElement(App, {root: scope}))
    const result = await compile({content, data})
    res.send(result)
  } catch (err) {
    console.error(err)
    res.status(500).send('something going wrong')
  }
}
github howtocards / frontend / src / pages / settings / page.js View on Github external
const AvatarSection = () =&gt; {
  const avatarUrl = useStore($avatarUrl)

  return (
    
      
        
        
      
    
  )
}
github howtocards / frontend / src / pages / home / page.js View on Github external
export const CardsHomePage = () =&gt; {
  const ids = useStore($cardsIds)
  const isLoading = useStore(homeCardsFetching.isLoading)

  React.useEffect(() =&gt; {
    pageReady()
  }, [])

  return (
    }&gt;
       <p>What about to create new card?</p>}
      /&gt;
    
  )
}
github howtocards / frontend / src / pages / edit / page.js View on Github external
const Title = () =&gt; {
  const title = useStore($title) || ""
  const titleRef = React.createRef()

  React.useEffect(() =&gt; {
    if (titleRef.current) {
      titleRef.current.focus()
    }
  }, [])

  return (
github howtocards / frontend / src / pages / view / page.js View on Github external
export const CardViewPage = ({ match }: Props) =&gt; {
  const cardId = parseInt(match.params.cardId, 10)

  React.useEffect(() =&gt; {
    cardLoading({ cardId })
  }, [cardId])

  const current = useStore($card)

  return (
    }&gt;
      {current ? (
        
      ) : (
        
      )}
    
  )
}
github howtocards / frontend / src / pages / users / current / page.js View on Github external
export const UserPage = ({ match }: Props) =&gt; {
  const [tab, setTab] = React.useState&lt;"created" | "useful"&gt;("useful")
  const userId = parseInt(match.params.userId, 10)

  const user = useStore($user)
  const { created, useful } = useStore($cards)
  const isLoading = useStore($isLoading)
  const isFailed = useStore($isFailed)
  const error = useStore($error)

  React.useEffect(() =&gt; {
    pageMounted({ userId })
  }, [userId])

  if (isFailed)
    return 

  return (
    }&gt;
       setTab("useful")}&gt;
        Useful
      
      |
github howtocards / frontend / src / pages / join / registration / page.js View on Github external
const RegisterForm = () =&gt; {
  const form = useStore($form)
  const formError = useStore(registerFetching.error)
  const isSubmitEnabled = useStore($isSubmitEnabled)

  return (
    <form>
      
        <h2>Registration to HowToCards</h2>
        {formError &amp;&amp; (
          {mapServerToClientError(formError.error)}
        )}
      
      
      
      
        Create account
      
    
  )</form>
github howtocards / frontend / src / pages / join / registration / page.js View on Github external
const Password = () =&gt; {
  const password = useStore($password)
  const isFormDisabled = useStore($isFormDisabled)
  const passwordError = useStore($passwordError)

  return (
    <input value="{password}" disabled="{isFormDisabled}" label="Password" autocomplete="password" name="password" type="password">
  )
}