react-streams icon indicating copy to clipboard operation
react-streams copied to clipboard

hook support...

Open babloo80 opened this issue 6 years ago • 1 comments

Hello there,

I am trying to use react-streams with upcoming hooks from react. And I am seeing some issues.

Here is what I am trying to do...

import React, {useContext} from 'react'
import {streamProps} from 'react-streams'
import {Ctx} from './Ctx'

const Component2 = streamProps( (props$) => {
  const ctx = useContext(Ctx)
  //want to use the ctx along to help transform some stream values of props$
  return props$
})

export default Component2

When the useContext hook is invoked, I get TypeError: dispatcher.useContext is not a function. Please advice on what alternatives I have?

Thanks, Muthu

babloo80 avatar Nov 18 '18 22:11 babloo80

My bad. Had some issues with package.json. I can interoperate with useContext. But, I do have a question. Do I have any hooks to perform cleanup like operation when the above Component2 goes thru an unmount process?

Also, I tried to use stream(source$, pipeOperation) inside an streamProps and attempted to combine streams (above stream and props$) did run into an error. From https://youtu.be/voVU3G7Y39A?t=1030, it seems like the functions have changed.

babloo80 avatar Nov 19 '18 00:11 babloo80